Snap.js icon indicating copy to clipboard operation
Snap.js copied to clipboard

Adding a fixed element to content container

Open smokingbarrel opened this issue 11 years ago • 17 comments

How to add a fixed element to content container so it doesn't get pushed when the drawer opens? I've tried adding an element with position: absolute !importantl; but it still gets pushed along with the content.

This mockup illustrates the feature I'd like to achieve: snap.js photo snap_zpsda7022dc.gif

smokingbarrel avatar Sep 10 '13 02:09 smokingbarrel

  1. Try to position the fixed div on the entire page and not in content div
  2. You may want to explore the snapper.on('open', function() function to hide the fixed div(set the css property inside the function) when the swipe event is triggered.

takrishna avatar Sep 10 '13 02:09 takrishna

@takrishna I've tried positioning the div outside of the snap.js-related divs and it just sits there on top of the drawer... The whole point is having that div inside of the content container which would act like a curtain when the drawer is open.

That being said, I think that second solution (just hiding) may not work as I intended because the whole wipe effect will be missing.

Just to make it clearer, I'd like to achieve similar masking effect as this page does when you scroll http://www.scootmedia.nl/

smokingbarrel avatar Sep 10 '13 03:09 smokingbarrel

@smokingbarrel
To fix the second step you may club with drawer status/state "animated" on the snapper.on function/state and then hide using css so the wipe effect persists.

May be for the positioning you can try to experiment with z-index and get the snapper above the content/fixed content, so that you have achieved the wipe effect ? if the z-index experiments work may be you do not require the second step at all

takrishna avatar Sep 10 '13 03:09 takrishna

I guess I can try to figure out the negative translate for that div once it's placed into the content container.

The z-index solution sounds more attractive though. The only problem is that the drawer sits under the content, once I change its z-index to the same z-index as content or above, the drawer just becomes a fixed side bar. Is there a trick to have drawer's z-index to be higher than the content's while retaining all the functionality?

smokingbarrel avatar Sep 10 '13 06:09 smokingbarrel

@jakiestfu any help here ?

u have a screen shot or something ?

Regards,

Krishna

On Tue, Sep 10, 2013 at 11:50 AM, smokingbarrel [email protected]:

I guess I can try to figure out the negative translate for that div once it's placed into the content container.

The z-index solution sounds more attractive though. The only problem is that the drawer sits under the content, once I change its z-index to the same z-index as content or above, the drawer just becomes a fixed side bar. Is there a trick to have drawer's z-index to be higher than the content's while retaining all the functionality?

— Reply to this email directly or view it on GitHubhttps://github.com/jakiestfu/Snap.js/issues/121#issuecomment-24136525 .

takrishna avatar Sep 10 '13 06:09 takrishna

Here are 2 sets of screenshots:

Set 1: content > z-index:2; .snap-drawer-left > z-index:1; red logo > z-index:3; position:absolute; (located outside of snap.js container) gold logo > lives inside of the left drawer

Closed drawer (red logo sits in a proper position):  photo ScreenShot2013-09-09at114047PM_zps02e84062.png

Open drawer (same position as the above because the stacking is off):  photo ScreenShot2013-09-09at114101PM_zpsd29c1333.png

Set 2: content > z-index:2; .snap-drawer-left > z-index:4; red logo > z-index:3; position:absolute; (located outside of snap.js container) gold logo > lives inside of the left drawer

Open drawer (now red logo is behind the drawer):  photo ScreenShot2013-09-09at114156PM_zpsb53449cf.png

Closed drawer (the content and toggle button goes behind the drawer, unable to collapse the drawer)  photo ScreenShot2013-09-09at114210PM_zpsb435be8b.png

Really appreciate your help Krishna

smokingbarrel avatar Sep 10 '13 06:09 smokingbarrel

Same issue here: https://github.com/jakiestfu/Snap.js/issues/85

fullstackdesign-xyz avatar Sep 17 '13 16:09 fullstackdesign-xyz

This can be accomplished not ideally by making the parent element fixed. Then have a child element, say a top bar, fixed with a set desired height and a separate child element, the content, fixed with 100% height. Set the parent element your container element in Snap. Here is a site I accomplished this on www.crosstek.net.

imjoeybrennan avatar Sep 18 '13 03:09 imjoeybrennan

Scroll down past the slideshow to see the fixed element effect. This is less then ideal because making everything fixed doesn't seem awesome, so being able to just set 2 container elements in Snap would be really great.

imjoeybrennan avatar Sep 18 '13 03:09 imjoeybrennan

Here is an example of setting multiple container elements with a simple panel menu like Snap http://jsfiddle.net/vishl/wzPSF/. Sorry for multiple comments, on my phone.

imjoeybrennan avatar Sep 18 '13 03:09 imjoeybrennan

@imjoeybrennan the example does not include snap. So, what's your point?

fullstackdesign-xyz avatar Sep 18 '13 10:09 fullstackdesign-xyz

@andreatorre the first example, www.crosstek.net, does use snap and accomplishes a fixed element, the header, which to see you must have your window at a width less than 768px and be scrolled down past the slideshow. However, it accomplishes this in a less then ideal method by making the parent fixed, the header fixed and the content fixed. I did figured this out by scoping out the code in this example, http://jakiestfu.github.io/Snap.js/demo/apps/ratchet/template.html. The second, fiddle example, http://jsfiddle.net/vishl/wzPSF/, is to show @jakiestfu that we can accomplish ideal fixed elements if we could set multiple Snap elements, Issue #85

imjoeybrennan avatar Sep 18 '13 19:09 imjoeybrennan

@jstxx, sorry, I meant multiple Snap container elements. That way multiple containers will shift over when a panel is opened.

imjoeybrennan avatar Sep 21 '13 20:09 imjoeybrennan

so, anyone found a solution for this? :)

scooterlord avatar Oct 03 '13 18:10 scooterlord

+1 for this (multiple element), but i think this should go back under issue #85

knynkwl avatar Sep 12 '14 19:09 knynkwl

+1

ashishsajwan avatar Feb 17 '15 11:02 ashishsajwan

+1

andreaguarino avatar Mar 15 '15 18:03 andreaguarino