Skip to content
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

setUnfixed function doesn't really brings back the element to its original status: think of MOBILE FIRST development approach [CONTAINS SOLUTION] #113

Open
MXTcomunica opened this issue Dec 10, 2013 · 2 comments

Comments

@MXTcomunica
Copy link

Hi all,

I'm using this fantastic plugin for my responsive layout, where a "mobile first" approach has been adopted.

So, I have a navigation element that has no css properties in "mobile" mediaqueries breakpoint and then it moves left and positioned fixed on "desktop" mediaqueries breakpoint.

So I used the 'minWidth' settings to remove 'scrollToFixed' stuff on this element for mobile mediaqueries (min-width < 768px), in this way:

$('#header-main').scrollToFixed({
marginTop: 30,
limit: function() {
var limit = $('#footer-main').offset().top - $('#header-main').outerHeight(true) - 20;
return limit;
},
zIndex: 10,
minWidth:768
});

The problem is that the above approach doesn't works well due this piece of code in setUnfixed function:

// Remove the style attributes that were added to the target.
// This will reverse the target back to the its original style.

target.css({
'width' : '',
'position' : originalPosition,
'left' : '',
'top' : originalOffset.top,
'margin-left' : ''
});

the above code writes inline css in my element that originally it doesn't have.
The result is a broken layout.

SOLUTION:

Changing the above code with:

target.removeAttr('style');

ALL WORKS FINE because all additional inline style is completely removed from my element and it really returns to its original condition.

Could you guys upgrade this plugin to reflect all the above stuff?

Thank you very much

MXT

@bigspotteddog
Copy link
Owner

As soon as I get a chance, I will take a look at this. Thanks!

@dunglas
Copy link
Contributor

dunglas commented Jan 12, 2014

@MXTcomunica's patch works for me. I'm using Twitter Boostrap in responsive mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants