Skip to content

Commit c4efb05

Browse files
authored
Merge pull request #5 from yama-dev/v0.4.0
V0.4.0
2 parents c0ba32d + c019cc4 commit c4efb05

File tree

4 files changed

+30
-17
lines changed

4 files changed

+30
-17
lines changed

dist/js-scroll-module.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/index.html

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,20 @@
2828
<body>
2929

3030
<div class="l-wrap">
31-
<div class="p-top">
31+
<div id="p-top" class="p-top">
3232
<p class="alert alert-secondary"> .p-top </p>
3333
</div>
34-
<div class="p-mid">
34+
<div id="p-mid" class="p-mid">
3535
<p class="alert alert-secondary"> .p-mid </p>
3636
</div>
37-
<div class="p-btm">
37+
<div id="p-btm" class="p-btm">
3838
<p class="alert alert-secondary"> .p-btm </p>
3939
</div>
4040
</div>
4141

4242
<nav class="p-nav">
43+
<p><a class="btn btn-secondary" href="#p-btm">#p-btm</a></p>
44+
<p><a class="btn btn-secondary" href=".p-btm">.p-btm</a></p>
4345
<button type="button" class="btn btn-secondary" data-scroll=".p-top">.p-top</button>
4446
<button type="button" class="btn btn-secondary" data-scroll=".p-btm">.p-btm</button>
4547
<button type="button" class="btn btn-secondary" data-scroll=".p-mid" data-scroll-header=".p-nav">.p-mid +.p-nav</button>
@@ -54,15 +56,26 @@
5456

5557
<script src="../dist/js-scroll-module.js"></script>
5658
<script>
57-
var JSM = new SCROLL_MODULE('[data-scroll]', {
58-
duration: 500,
59-
easing: SCROLL_MODULE.easeOutQuart,
60-
trueFunction: function(){
61-
if(window.innerWidth <= 765){
62-
return true;
63-
}
59+
var JSM = new SCROLL_MODULE('[data-scroll]', {
60+
duration: 500,
61+
easing: SCROLL_MODULE.easeOutQuart,
62+
trueFunction: function(){
63+
if(window.innerWidth <= 765){
64+
return true;
6465
}
65-
});
66+
}
67+
});
68+
</script>
69+
<script>
70+
var JSM = new SCROLL_MODULE('[href^="#"]', {
71+
duration: 500,
72+
easing: SCROLL_MODULE.easeOutQuart,
73+
trueFunction: function(){
74+
if(window.innerWidth <= 765){
75+
return true;
76+
}
77+
}
78+
});
6679
</script>
6780

6881
</body>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@yama-dev/js-scroll-module",
3-
"version": "0.3.1",
3+
"version": "0.4.0",
44
"description": "",
55
"keywords": [
66
"module",

src/js-scroll-module.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class SCROLL_MODULE {
5151

5252
_attachEvent(){
5353
DOM.addEvent(this.state.elem_array, 'click', (e)=>{
54-
let _elem_target_data = e.currentTarget.getAttribute(this.state.elem_selector.replace(/(\[|\])/g,''));
54+
let _elem_target_data = e.currentTarget.getAttribute(this.state.elem_selector.replace(/(\[|\]|\^|=|"|#)/g,''));
5555
let _elem_target_data_header = e.currentTarget.getAttribute('data-scroll-header');
5656
let _elem_target_data_offset = e.currentTarget.getAttribute('data-scroll-offset');
5757
let _elem_target_data_true_offset = e.currentTarget.getAttribute('data-scroll-true-offset');
@@ -145,8 +145,8 @@ export class SCROLL_MODULE {
145145
this._animeFunctionPrep(target, duration, header, offset, trueOffset);
146146
}
147147

148-
static easeOutQuart(elapsed, initialValue, amountOfChange, duration){
149-
return -amountOfChange * ((elapsed = elapsed / duration - 1) * elapsed * elapsed * elapsed - 1) + initialValue;
148+
static easeOutQuart(t, b, c, d){
149+
return -c * ((t = t / d - 1) * t * t * t - 1) + b;
150150
}
151151

152152
static easeOutCubic(t, b, c, d) {

0 commit comments

Comments
 (0)