-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
97392e4
commit 090ea73
Showing
9 changed files
with
550 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,2 +1,7 @@ | ||
# christmas | ||
一个漂亮的圣诞节动画🎄 | ||
|
||
![一个漂亮的圣诞节动画🎄](https://github.com/shunyue1320/christmas/blob/main/example.gif) | ||
|
||
展示地址:[https://shunyue1320.github.io/christmas](https://shunyue1320.github.io/christmas) | ||
素材来源:[https://codepen.io/chrisgannon/details/KZMYmp](https://codepen.io/chrisgannon/details/KZMYmp) |
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,75 @@ | ||
window.ScrubGSAPTimeline = (tl) => { | ||
let mainTl = new TimelineLite(); | ||
if (Object.prototype.toString.call(tl) === '[object Array]') { | ||
let i = tl.length; | ||
while (--i > -1) { | ||
mainTl.add(tl[i], 0); | ||
} | ||
|
||
} else { | ||
mainTl = tl; | ||
} | ||
const Scrubber = (_tl) => { | ||
|
||
let mouseMove = (e) => { | ||
box.innerHTML = parseFloat(_tl.time()).toFixed(2); | ||
_tl.pause(); | ||
_tl.progress(e.clientX / (window.innerWidth)); // * tl.duration(); | ||
mouseX = e.clientX, mouseY = e.clientY; | ||
|
||
TweenLite.set(box, { | ||
x: (mouseX >= (window.innerWidth - 48)) ? mouseX - 48 : mouseX, | ||
y: (mouseY <= 20) ? mouseY + 20 : mouseY - 20 | ||
}) | ||
}, | ||
mouseOver = (e) => { | ||
_tl.pause(); | ||
_tl.play(0); | ||
TweenLite.set(box, { | ||
autoAlpha: 1 | ||
}) | ||
}, | ||
mouseOut = (e) => { | ||
_tl.play(e.clientX / (window.innerWidth) * _tl.duration()); | ||
TweenLite.set(box, { | ||
autoAlpha: 0 | ||
}) | ||
}, | ||
box = document.createElement('div'), | ||
mouseX, mouseY, gGreen = '#53A018', | ||
cssText = "position:fixed;border-radius:4px;font-size:14px;padding:5px;user-select:none;pointer-events:none;text-align:center;color:#53A018;top:0;left:0;font-family:Helvetica, Arial, sans-serif;background-color:#262626;line-height:1 !important;z-index:99999999" | ||
box.style.cssText = cssText; | ||
|
||
document.body.appendChild(box); | ||
document.body.onmousemove = mouseMove; | ||
document.body.onmouseover = mouseOver; | ||
document.body.onmouseout = mouseOut; | ||
document.body.ondblclick = (e) => { | ||
if (!document.body.onmousemove) { | ||
TweenLite.to(box, 0.2, { | ||
color: gGreen | ||
}) | ||
document.body.onmousemove = mouseMove; | ||
document.body.onmouseover = mouseOver; | ||
document.body.onmouseout = mouseOut; | ||
return; | ||
} | ||
|
||
TweenLite.to(box, 0.2, { | ||
color: '#A31632' | ||
}) | ||
document.body.onmousemove = null; | ||
document.body.onmouseover = null; | ||
document.body.onmouseout = null; | ||
_tl.pause(); | ||
|
||
} | ||
|
||
|
||
} | ||
|
||
Scrubber(mainTl); | ||
|
||
|
||
|
||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.