-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using plugin with asp.net #15
Comments
Can you provide an example? Headhesive clones your target element, so if you have an id on it, it will duplicate it, regardless of language. If there is no way of removing the ID from your markup, I'll take a look into a solution. |
Actually, even if you changed IDs in runtime, that would still might break .net controls. The solution for avoiding that, would be not to clone an element but move it. To avoid the gap, you could insert an empty DIV with the same height as the moved element. When user scrolls up again, that DIV is replaced by the moved element. Cloning is not the way to go since duplicating elements that can have IDs generates incorrect html. Do you think headhesive could work with a moved copy instead of a cloned one? |
I've no understanding of asp.net, so apologies if this is an obvious question; is it injecting ID's that you're unable to control? If you could put up an example somewhere, that'd be great. I had looked at ways to not clone the element, unfortunately I couldn't find a neat solution at the time, but I think the option to do so would be great. When I looked at it before, the animation side was the issue, I'll have a re-think on this. |
Forget about .net. That was just an example where the problem will come up sooner or later for those using this script. The important issue here is that cloning an existing element will always be incorrect for the reasons I already mentioned. Using jQuery it would be easy to develop something like this:
Going down...
Going up...
This solution will allow for the fixed header to appear only when the user scrolls past its initial position, or even a custom position passed as a parameter. What do you think? |
I'm not sure I follow 100%. Are you saying we should only show the header after the target scroll position? The purpose of the plugin is to allow a header that isn't fixed and visible as soon as you hit the page, and then kind of "lazy load" in after so far down. This is still possible without cloning the element, I just need to figure the nicest solution ;). |
The behavior I described is exactly like the one in your demo (http://markgoodyear.com/labs/headhesive/), but without cloning.You only show the fixed menu after some scrolling right (offset)? It's not visible as soon as the page loads. My InitPosition is your offset i guess :) |
Yeah, I definitely agree this should be in the plugin. Sometimes the cloning has caused issues for me on other projects. What would the purpose be of the injected div? I reckon there will be a neater way of doing it without injecting divs (maybe!). I'll hopefully get chance to have a look at this over the weekend. |
Making an element fixed, will have the same effect as if you removed it from the DOM. You will see everything below that element jump to fill the gap. By injecting a div with the same height, you will be avoiding that annoying jump. This doesn't happen with your plugin because you duplicate the element so the original one stays in place. If you have a chance to test anything, It would be my pleasure to take a peak into it so that I can give you my opinion :) |
Ah yes, that could work. I was thinking to add a margin-top to the body element to push it down — will test out both ways to see, but the div idea I think may be the better. Thanks, I'll give you a shout when theres something to have a look at :) |
Today I found a website with a header bar behaving just like we discussed. The script is inside jquery.theme.home.js. |
I've pushed some updates to the The demo is set up to not clone the element, you'll be able to see the small issue I have with the animation. As soon as you go back up, because we essentially remove Any feedback is appreciated! |
Hi Mark, sorry for the delay. busy week :) Checked your demo, uncommented the no clone version, and even changed the data attribute of the header tag to clone: false but it's not working. I only get two visible header bars. Can you make sure the demo is working? |
It was working for me before pushing, let me just double check. I think I'll remove the whole data-attribute configure thing, and look at it another time. |
It's all working for me — could you remove the header with the data configuration? Basically at the moment, one config will overwrite the other. You can leave the data config in and just use Let me know if that doesn't work. |
Hi Mark, tested again and only get two visible header bars upon load. The only init code I have now is /**
and in the HTML I removed the header with data config as you said:
I tested on Firefox and IE 9. Debugged using Firebug and noticed that _getDataOptions(this.elem.dataset.headhesive); is returning nothing and overwriting the options specified in html code, so on the next line you merge default options with nothing. After commenting that line, it works. I suppose that _getDataOptions is for options defined by data attributes right? If so, you should check for null values. Now that this is solved i'm going to see how it's working. |
The issue with the animation when scrolling up is simple to solve. You can't just remove the .banner--stick class, because that, will immediately make the element non fixed and jump right into its place. Before removing that class, you must apply another one (.banner--hide), a little bit before the user reaches the offset point (offset-100px), with only the animation to make it disappear. Only after users passes offset point, you can remove the .banner--stick class. Once the user reaches the initial header bar position+it's height, you also remove the .banner--hide. The advantage with this method is that if the user decides to scroll back down before reaching the initial header position, you just have to remove the .banner--hide class and the header will appear again in it's fixed position. You might have to change your current animation styles for this to work. |
Hi Mark, any updates? |
Hey @HybridSolutions, unfortunately I've had no time to work on personal projects, work has been very busy! I'll try fit it in when I can :) |
Cloning elements can cause duplicate id's and that happens when using asp.net. It would be great to have the option not to clone, but move instead allowing the plugin to work in every scenario.
The text was updated successfully, but these errors were encountered: