
Enhancing the user experience (UX) of a website requires dynamic visual effects that trigger as content appears. This article explains how to use HubSpot CMS "Custom Modules" to allow editors to freely control element animations directly from the edit screen, without requiring any programming knowledge.


Enhancing the user experience (UX) of a website requires dynamic visual effects that trigger as content appears. This article explains how to use HubSpot CMS "Custom Modules" to allow editors to freely control element animations directly from the edit screen, without requiring any programming knowledge.
The goal of this module is to centrally manage "which element," "how," and "when" to animate via the HubSpot page editor, without manually adding specific CSS classes.
animation_controller) and create it.Copy and paste the code provided in the technical specifications into the respective sections of the module editor:
@keyframes. IntersectionObserver. Configure specific movements within the "anim_settings" panel of the placed module:
h2, img) from the dropdown. 1s). Create a "New Module" in the HubSpot Design Manager and paste the following code into each respective section.
This is the field definition. It consists of a repeater field (Items) and style setting fields (Styles).
[
{
"children": [
{
"choices": [
[ "h1", "H1" ], [ "h2", "H2" ], [ "h3", "H3" ], [ "h4", "H4" ],
[ "h5", "H5" ], [ "h6", "H6" ], [ "p", "p" ], [ "span", "span" ],
[ "div", "div" ], [ "li", "list" ], [ "img", "image" ], [ "setion", "section" ]
],
"display": "select",
"display_width": null,
"id": "6b6e5314-9832-c18b-b7f1-e5ab1052fabb",
"label": "target_selector",
"locked": false,
"multiple": false,
"name": "target_selector",
"preset": null,
"reordering_enabled": true,
"required": false,
"type": "choice"
},
{
"choices": [
[ "slide-in", "slide-in" ], [ "slide-out", "slide-out" ],
[ "scale-up", "scale-up" ], [ "wave", "wave" ],
[ "bounce", "bounce" ], [ "scale-down", "scale-down" ], [ "pop-up", "pop-up" ]
],
"display": "select",
"display_width": null,
"id": "d604cb29-9753-6dc8-fd76-e5828e86f0d2",
"label": "anim_type",
"locked": false,
"multiple": false,
"name": "anim_type",
"preset": null,
"reordering_enabled": true,
"required": false,
"type": "choice"
},
{
"choices": [
[ "down", "上から" ], [ "up", "下から" ],
[ "left", "左から" ], [ "right", "右から" ], [ "none", "なし" ]
],
"display": "select",
"display_width": null,
"id": "a7c1f435-7a80-f31b-5c9e-b827edf28bc8",
"label": "direction",
"locked": false,
"multiple": false,
"name": "direction",
"preset": null,
"reordering_enabled": true,
"required": false,
"type": "choice"
},
{
"display": "text",
"display_width": null,
"id": "c15cf622-810b-0753-bc04-211167da8095",
"label": "duration",
"locked": false,
"name": "duration",
"required": false,
"step": 1,
"type": "number"
},
{
"display": "text",
"display_width": null,
"id": "72e19799-ddd8-060f-4955-5ecdcd781bd9",
"label": "delay",
"locked": false,
"name": "delay",
"required": false,
"step": 1,
"type": "number"
}
],
"default": [],
"display_width": null,
"expanded": false,
"group_occurrence_meta": null,
"id": "f1529db5-e7c4-bba2-3b9a-e69444442236",
"label": "anim_settings",
"locked": false,
"name": "anim_settings",
"occurrence": {},
"required": false,
"tab": "CONTENT",
"type": "group"
}
]{# アニメーション設定をJavaScriptに渡す #}
<script>
window.hsAnimConfig = window.hsAnimConfig || [];
{% if module.anim_settings %}
{% for item in module.anim_settings %}
window.hsAnimConfig.push({
selector: "{{ item.target_selector }}",
type: "{{ item.anim_type }}",
direction: "{{ item.direction|default('none') }}",
duration: "{{ item.duration|default(1) }}s",
delay: "{{ item.delay|default(0) }}s"
});
{% endfor %}
{% endif %}
console.log('HubSpot Animation Config:', window.hsAnimConfig);
</script>/* 基本設定 */
.js-anim-ready {
opacity: 0 !important;
}
/* アニメーション実行中 */
.js-anim-active {
opacity: 1 !important;
}
/* === スライドイン === */
@keyframes slideInFromTop {
from { opacity: 0; transform: translateY(-50px); }
to { opacity: 1; transform: translateY(0); }
}
@keyframes slideInFromBottom {
from { opacity: 0; transform: translateY(50px); }
to { opacity: 1; transform: translateY(0); }
}
@keyframes slideInFromLeft {
from { opacity: 0; transform: translateX(-50px); }
to { opacity: 1; transform: translateX(0); }
}
@keyframes slideInFromRight {
from { opacity: 0; transform: translateX(50px); }
to { opacity: 1; transform: translateX(0); }
}
/* === スライドアウト === */
@keyframes slideOutToTop {
from { opacity: 1; transform: translateY(0); }
to { opacity: 0; transform: translateY(-50px); }
}
@keyframes slideOutToBottom {
from { opacity: 1; transform: translateY(0); }
to { opacity: 0; transform: translateY(50px); }
}
/* === その他のアニメーション === */
@keyframes scaleUp {
from { opacity: 0; transform: scale(0.5); }
to { opacity: 1; transform: scale(1); }
}
@keyframes scaleDown {
from { opacity: 0; transform: scale(1.5); }
to { opacity: 1; transform: scale(1); }
}
@keyframes wave {
0% { opacity: 0; transform: translateX(-20px) rotate(0deg); }
50% { opacity: 0.5; transform: translateX(10px) rotate(2deg); }
100% { opacity: 1; transform: translateX(0) rotate(0deg); }
}
@keyframes bounce {
0% { opacity: 0; transform: translateY(50px); }
50% { opacity: 1; transform: translateY(-10px); }
100% { opacity: 1; transform: translateY(0); }
}
@keyframes popUp {
from { opacity: 0; transform: translateY(20px) scale(0.8); }
to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}No, that is not necessary. This module allows you to add settings in a list format within the "anim_settings" panel. You can centrally manage multiple different targets—such as setting H2 tags to slide from the bottom while images pop up with a one-second delay—all within a single module.
o. The module utilizes the "Intersection Observer API," which detects when an element is at least 10% visible within the viewport. Animations are triggered naturally according to the user's scrolling behavior.
No, they are automatically excluded. To protect the user experience, the script includes a function that automatically identifies elements within headers or footers and excludes them from animation processing. This allows users to focus on animating main content without worrying about affecting global site areas.
We can customize this sample to match your specific business requirements.
Book Free ConsultationPut it on Trello!Need a fix for HubSpot, CMS, or GAS? Post it on Trello.
Development Requests Here