Page Scroll Animation Plugin delighters.js

Add-ons
2026-07-25 22:44 3 次浏览 • 0 次下载 3.8KB
Page Scroll Animation Plugin delighters.js

Usage

Include the delighters.js.js file in your page.

1
<script type="text/javascript" src="js/delighters.js.js"></script>

HTML Structure

Add the data-delighter attribute to elements that need animation effects.

1
<div> class="foo" data-delighter </div>

CSS Styles

The built-in .started and .ended classes automatically apply styles to elements with the data-delighter attribute (or their child elements).

After the plugin is loaded, each data-delighter element is assigned a .delighter class.

1
2
3
4
5
.foo.delighter {
transition: all .3s ease-out;
transform: translateX(-100%);
opacity: 0;
}

The .started class is added to an element when it enters the viewport at the 0.75 position from the top (0 represents the very top, and 1 represents the very bottom).

1
2
3
4
.foo.delighter.started {
transform: none;
opacity: 1;
}

The .ended class is added to an element when it reaches the 0.75 position from the top of the viewport (0 represents the very top, and 1 represents the very bottom).

1
2
3
.foo.delighter.started.ended {
border: solid red 10px;
}

Custom Configuration Options

Normally, the plugin initializes automatically after the DOM elements have finished loading. Its default configuration options are as follows:

1
2
3
4
5
6
7
options = {
attribute: 'data-delighter',
classNames: ['delighter', 'started', 'ended'],
start: 0.75, // Default start threshold
end: 0.75, // Default end threshold
autoInit: true // Initialize on DOMContentLoaded
}

You can modify the plugin's default configuration options using the following method:

1
2
3
4
5
6
7
Delighters.config({
// Set the default start threshold at the bottom
start: 1,
// Call Delighters.init() manually later
autoInit: false
// ... etc ...
})
星河码客

发现和分享优质开源项目,传承互联网精神,为开发者服务。

关于本站

联系我们

微信/广告合作:ITcloub (备注星河码客)

免责声明:本站资源版权归原作者所有,仅供学习与交流。如有侵权,请通过「关于我们 - 侵权投诉」联系删除。

Powered by Nuxt · Deployed on Cloudflare