-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- refactor property and target value management the prop now calls the target instead of the otherway around
- Loading branch information
1 parent
74a1cf0
commit 91d693b
Showing
8 changed files
with
419 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
export default class ScrollEvent { | ||
constructor() { | ||
this._listeners = new Set; | ||
|
||
window.addEventListener('scroll', e => this._onScroll(e)); | ||
} | ||
|
||
static global() { | ||
if (typeof window === 'undefined') | ||
return null; | ||
|
||
if (typeof window.chnobliScroll === 'undefined') | ||
window.chnobliScroll = new ScrollEvent; | ||
return window.chnobliScroll; | ||
} | ||
|
||
add(fn) { | ||
this._listeners.add(fn); | ||
|
||
return { | ||
remove: () => { | ||
this.remove(fn); | ||
} | ||
}; | ||
} | ||
|
||
remove(fn) { | ||
this._listeners.delete(fn); | ||
} | ||
|
||
_onScroll(e) { | ||
for (const fn of this._listeners) { | ||
fn({ | ||
y: window.scrollY, | ||
height: window.innerHeight | ||
}, { | ||
remove: () => this.remove(fn) | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import Scroll from './scroll.js'; | ||
|
||
export default class PublicScroll { | ||
/* | ||
{ | ||
start: el | px | ||
startView: 'top' | ||
} | ||
*/ | ||
constructor(props = {}) { | ||
this._inner = new Scroll(props); | ||
} | ||
|
||
add(timeline) { | ||
this._inner.addTimeline(timeline); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.