Skip to content

Instantly share code, notes, and snippets.

@dbismut
Last active April 9, 2018 08:10
Show Gist options
  • Save dbismut/f2e9e581c0feaf13e66480740bd90935 to your computer and use it in GitHub Desktop.
Save dbismut/f2e9e581c0feaf13e66480740bd90935 to your computer and use it in GitHub Desktop.
Part 3 - Adding scale to transition from drag and compensate viewport scroll in this.to
onExit = () => {
this.removeListeners();
if (!this.preview) return;
const scale = 1 - this.state.dragProgress * (1 - DRAG_MINIMUM_SCALE);
this.from = {
top: 0,
height: this.post.offsetHeight,
width: this.post.offsetWidth,
borderRadius: this.postStyler.get('borderRadius'),
scale, // add scale right there
scrollTop: windowScroll.get('top')
};
this.to = {
...this.getPreviewStyleAndPosition(),
scrollTop: 0
};
// setting destination top to compensate
// for the drag
if (this.isTransitioningFromDrag) {
this.to.top += windowScroll.get('top');
}
/* same code */
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment