Skip to content

React Animation Transition Issue #247

Open
@dailenspencer

Description

@dailenspencer

Hey guys,

I've been cooking on an issue for awhile and cant seem to figure out the root of it. My site is a SPA built on React.js and uses animations to transition from url to url.

When the user transitions from the blog page(www.dailenspencer.com/blog) to a blog post page (www.dailenspencer.com/blog/0001) - parallax doesnt work as expected.

Case 1(failure case):
• head to www.dailenspencer.com/blog
• click on the first blog item to initialize the transition to the page with parallax.js
• result: parallax.js not working.

Case 2(failure case):
• head to www.dailenspencer.com/blog/0001
• result: parallax.js is working

Case 3(success case):
• head to www.dailenspencer.com/blog
• click on the first blog item to initialize the transition to the page with parallax.js
• click the back button and then re-click on the first blog item
• result: parallax.js is working

Case 4(success case):
• head to www.dailenspencer.com/blog/0001
• hit the back button
• click on the first blog item to initialize the transition to the page with parallax.js
• result: parallax.js is working

My conclusion is that the parallax.js implementation is working as expected, only when the user loads up a clean page(i.e. hit www.dailenspencer.com/blog/0001) OR when the user initializes parallax.js once(doesnt work first time around), and then leaves the page and returns.

I'm using the Alpha version. Here is my parallax.js initialization

$('.parallax-window').parallax({
    speed: .2,
    sliderSelector: '>.parallax-slider',
    mirrorSelector: '.page-blogpost',
    scrollingSelector: '.page-blogpost'
})

You can see the HTML/CSS on the live site at www.dailenspencer.com/blog/0001

At first, I thought this issue would be related to parallax.js not re-calculating the window size when the animation starts/ends. But i've added a Mutation Observer that watches for the animation and then rapidly calls a resize & scroll event throughout the animation.
$(window).trigger('resize').trigger('scroll')
If you head to dailenspencer.com and perform the correct steps(head from dailenspencer.com/blog -> dailenspencer.com/blog/0001), you will see the resize console log being triggered. The numbers are coming from a log I placed inside the loadDimensions() function.

Parallax.wH = $win.height();
Parallax.wW = $win.width();
Parallax.dH = $se[0].scrollHeight || $se.height();
Parallax.dW = $se[0].scrollWidth || $se.width();
console.log(Parallax.wH, Parallax.wW, Parallax.dH, Parallax.dW)

These numbers are very consistent so I know its not the window calculation causing the issue :/

As I continue to investigate i'll be making some updates to this issue. If anyone would like access to the repo i'd be happy to add you on. I've made a few minor changes to jquery.parallax.js but none that I see would cause this sort of issue. Will appreciate any and all help!!

UPDATE:
With further investigation, I can see now that the results vary from load to load. You may find that the cases I laid out before do not match your results.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions