-
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.
Merge pull request #68 from mbaraa/dev
release v0.1.0
- Loading branch information
Showing
15 changed files
with
382 additions
and
87 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* I herby admit that this code is a copy-pasta from https://developer.chrome.com/blog/overscroll-behavior/ */ | ||
|
||
body.refreshing #main-contents, | ||
body.refreshing header { | ||
filter: blur(1px); | ||
touch-action: none; | ||
} | ||
|
||
body.refreshing .refresher { | ||
transform: translate3d(0, 150%, 0) scale(1); | ||
z-index: 50; | ||
visibility: visible; | ||
} | ||
|
||
.refresher { | ||
pointer-events: none; | ||
--refresh-width: 55px; | ||
background: var(--secondary-color); | ||
width: var(--refresh-width); | ||
height: var(--refresh-width); | ||
border-radius: 50%; | ||
position: absolute; | ||
left: calc(50% - var(--refresh-width) / 2); | ||
padding: 8px; | ||
box-shadow: | ||
0 2px 2px 0 rgba(0, 0, 0, 0.14), | ||
0 1px 5px 0 rgba(0, 0, 0, 0.12), | ||
0 3px 1px -2px rgba(0, 0, 0, 0.2); | ||
transition: all 0.5s cubic-bezier(0, 0, 0.2, 1); | ||
will-change: transform; | ||
display: inline-flex; | ||
justify-content: space-evenly; | ||
align-items: center; | ||
visibility: hidden; | ||
} | ||
|
||
body.refreshing .refresher.shrink { | ||
transform: translate3d(0, 150%, 0) scale(0); | ||
opacity: 0; | ||
} | ||
|
||
.refresher.done { | ||
transition: none; | ||
} | ||
|
||
.loading-bar { | ||
background-color: var(--primary-color); | ||
width: 4px; | ||
height: 18px; | ||
border-radius: 4px; | ||
animation: loading 0.81s ease-in-out infinite; | ||
} | ||
|
||
.loading-bar:nth-child(1) { | ||
animation-delay: 0; | ||
} | ||
.loading-bar:nth-child(2) { | ||
animation-delay: 0.09s; | ||
} | ||
.loading-bar:nth-child(3) { | ||
animation-delay: 0.18s; | ||
} | ||
.loading-bar:nth-child(4) { | ||
animation-delay: 0.27s; | ||
} | ||
|
||
@keyframes loading { | ||
0% { | ||
transform: scale(1); | ||
} | ||
20% { | ||
transform: scale(1, 2.2); | ||
} | ||
40% { | ||
transform: scale(1); | ||
} | ||
} |
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,62 @@ | ||
/* I herby admit that this code is a copy-pasta from https://developer.chrome.com/blog/overscroll-behavior/ */ | ||
|
||
"use strict"; | ||
|
||
const mainContentsEl = document.getElementById("main-contents"); | ||
let _startY = 0; | ||
|
||
async function simulateRefreshAction() { | ||
const sleep = (timeout) => | ||
new Promise((resolve) => setTimeout(resolve, timeout)); | ||
|
||
const transitionEnd = function (propertyName, node) { | ||
return new Promise((resolve) => { | ||
function callback(e) { | ||
e.stopPropagation(); | ||
if (e.propertyName === propertyName) { | ||
node.removeEventListener("transitionend", callback); | ||
resolve(e); | ||
} | ||
} | ||
node.addEventListener("transitionend", callback); | ||
}); | ||
}; | ||
|
||
const refresher = document.querySelector(".refresher"); | ||
|
||
document.body.classList.add("refreshing"); | ||
await sleep(500); | ||
|
||
refresher.classList.add("shrink"); | ||
await transitionEnd("transform", refresher); | ||
refresher.classList.add("done"); | ||
|
||
refresher.classList.remove("shrink"); | ||
document.body.classList.remove("refreshing"); | ||
await sleep(0); // let new styles settle. | ||
refresher.classList.remove("done"); | ||
} | ||
|
||
document.body.addEventListener( | ||
"touchstart", | ||
(e) => { | ||
_startY = e.touches[0].pageY; | ||
}, | ||
{ passive: true }, | ||
); | ||
|
||
document.body.addEventListener( | ||
"touchmove", | ||
async (e) => { | ||
const y = e.touches[0].pageY; | ||
if ( | ||
document.scrollingElement.scrollTop === 0 && | ||
y > _startY + 150 && | ||
!document.body.classList.contains("refreshing") | ||
) { | ||
await simulateRefreshAction(); | ||
await updateMainContent(window.location.pathname); | ||
} | ||
}, | ||
{ passive: true }, | ||
); |
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
Oops, something went wrong.