Famo.us/Angular Sticky Background Position ScrollView Sync -



Famo.us/Angular Sticky Background Position ScrollView Sync -

i'm trying create functionality similar websites these days.

the concept 3 sections size of browser, background images supposed fixed positioned , revealed div scrolling , down.

we need function beautifully on mobile on desktop, , looks famous/angular solution.

here pen. http://codepen.io/lazzam2/pen/xjrwbo

i'm using famous' scroll.sync, firing javascript positions background image on every start / update / end.

scrollobject.sync.on("update", function (event) { console.log('update'); test(event); });

here function positioning backgrounds.

function test(data){ var scroller = document.getelementsbyclassname('famous-group'); styles = window.getcomputedstyle(scroller[0], null); tr = styles.getpropertyvalue("-webkit-transform").replace('matrix(1, 0, 0, 1, 0,','').replace(')',''); var distancetop = -(parseint(tr)); var sections = document.getelementsbyclassname('section'); sections[3].style.backgroundposition="50% "+distancetop+"px"; sections[4].style.backgroundposition="50% "+(-(window.innerheight)+distancetop)+"px"; sections[5].style.backgroundposition="50% "+(-(window.innerheight*2)+distancetop)+"px"; };

any input / suggestions / advice wonderful, looking proof of concept these 3 background images scrolling nicely.

that jittery-ness unfortunate, can't tell causing issue, except maybe order in events fired?

**there known issues, works in -webkit browsers of now

i think thought utilize famous good, do, taking different approach problem. solving touching dom, both angular , famous meant avoid. if had face same goal, utilize famous surface background instead of changing property of main 1 , synchronize position scrolling view. so, in code, this:

function test(data){ var scrollviewposition = scrollobject.getabsoluteposition(); var newbackgroundposition = // calculate new background position var newforegroundposition = // calculate new foreground position var backgroundsurface = backgroundsurface.position.set(newbackgroundposition); var foregroundsurface = foregroundsurface.position.set(newforegroundposition); };

background famo.us famous-angular

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -