View .eslintrc.json
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
Show hidden characters
{ | |
"env": { | |
"browser": true, | |
"commonjs": true, | |
"es6": true, | |
"jest": true, | |
"node": true | |
}, | |
"globals": {}, | |
"parser": "/Users/david/repos/useAudioPlayer/node_modules/babel-eslint/lib/index.js", |
View Post.js
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
render() { | |
/* ... */ | |
const { closeInverted, dragProgress } = this.state; // change the state | |
return ( | |
/* same code */ | |
// this will add the invert class | |
// when this.state.closeInverted is true | |
<div |
View Post.js
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
state = { | |
dragProgress: 0, | |
closeInverted: false, | |
}; | |
onScroll = () => { | |
/* same code */ | |
// handling close icon color | |
const threshold = scrollTop / CLOSE_INVERTED_THRESHOLD; |
View Post.scss
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
.close.invert { | |
background: #000; | |
&::after, | |
&::before { | |
background: #fff; | |
} | |
} |
View Post.js
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
executeEnteringTransition = (node, done) => { | |
/* same code */ | |
const { | |
height: heightFrom, | |
top: topFrom, | |
scale: scaleFrom, | |
...mainFrom | |
} = this.from; | |
const { height: heightTo, top: topTo, scale: scaleTo, ...mainTo } = this.to; |
View Post.js
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
getPreviewStyleAndPosition = () => { | |
const { top, width, height } = this.preview.getBoundingClientRect(); | |
const transformMatrix = window.getComputedStyle(this.preview).transform; | |
// transformMatrix is either 'none', or a string in the form of | |
// matrix(0.965, 0, 0, 0.965, 0, 0) | |
const scale = | |
transformMatrix.indexOf('matrix') === 0 | |
? parseFloat(transformMatrix.split(', ')[3]) |
View Preview.js
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
import React, { PureComponent } from 'react'; | |
import Pressure from 'pressure'; | |
const PRESSED_SCALE = 0.95; | |
// minimum scale applied to the preview node | |
export default class Preview extends PureComponent { | |
state = { force: 0 }; | |
timer = null; |
View Post.scss
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
.page-post { | |
&.post-exit, | |
&.post-enter { | |
.content, | |
.close, | |
.underlay { | |
opacity: 0; | |
} | |
.underlay { | |
transition-delay: 0; |
View Post.js
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
executeEnteringTransition = (node, done) => { | |
this.postStyler.set({ ...this.from, visibility: 'visible' }); | |
node.classList.add('post-enter-started'); // add this line | |
/* same code */ | |
complete: () => { | |
node.classList.remove('post-enter-started'); // add this line | |
done(); | |
} |
View Post.js
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
/* other imports */ | |
import browser from 'bowser'; // the browser import | |
/* ... */ | |
executeEnteringTransition = (node, done) => { | |
this.postStyler.set({ ...this.from, visibility: 'visible' }); | |
const hidePreview = () => (this.preview.style.visibility = 'hidden'); |
NewerOlder