-
Notifications
You must be signed in to change notification settings - Fork 122
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
Set other classes/properties at breakpoint? #14
Comments
Thoughts? |
Yo watch this video I think "attr" functionality is a great idea. Something like this I reckon: Response.create({
prefix: "placeholder"
, attr: "placeholder" // < does not exist now but should be easy to implement
, prop: "width"
, breakpoints: [0, 481]
}); in order to write html like: <input placeholder="John Doe" data-placeholder-481="Mickey Mouse"> Right? A safe way to do it right now (v 0.7.0) is like: (function ($, R) {
$(function () {
var $input = $('input');
if ( !$input.length ) { return; }
// copy initial placeholder values to data-placeholder
// `R.store(els, key [, attrToReadFrom])`
R.store($input, 'placeholder', 'placeholder'); // 3rd arg @since 0.7.0
R.resize(function () {
$input.each(function () {
var newVal = R.band(481) ? R.dataset(this, 'placeholder') : 'small';
null == newVal || $(this).attr('placeholder', newVal);
});
});
});
}(jQuery, Response)); Although if you're not using Response elsewhere then I would just do it all in jQuery: (function ($, win) {
$(function () {
var $input = $('input'), $win = $(win);
if ( !$input.length ) { return; }
$input.each(function() {
this.setAttribute('data-placeholder', this.getAttribute('placeholder') || '');
});
$win.resize(function () {
$input.each(function () {
var newVal = $win.width() < 481 ? 'small' : this.getAttribute('data-placeholder');
null == newVal || this.setAttribute('placeholder', newVal);
});
});
});
}(jQuery, window)); Also there is |
@alanhogan Cool / I'll add the attr functionality in soon ( prob. early Sept ). It should be easy enough. There are several issues with the event methods that I'm hoping to have sorted for version 0.8. I agree, the direction etc. makes sense for the crossover. I think it'd also be useful to be able to add a crossover listener w/o having to first set up a breakpoint set via Response.crossover('width', [641, 961], function (eventData) {
// fires when viewport width crosses 641 or 961
}); |
Ryan, if you’d like to see the code I ended up using here, I’d be happy to email it to you. Figured it might be interesting as you continue to develop the library and consider adding features like the ones you mentioned above. I’m pretty sure I did some silly things, but basically I created a layer over |
@alanhogan Sure it's |
There is a case where simply swapping a class name or two and maybe setting/unsetting the
placeholder
property oninput
elements would sufficiently mobile-ize a form I have.I do not want to overwrite the DOM/innerHTML of the form, because if the user re-sizes their window while filling out the form, I understand their data would be lost. (Not to mention it’s a ridiculous HTML weight overhead for what I want to achieve).
Is there a way to do this using response.js? As far as I could tell, either of these would work:
src
) on elements for various breakpoints, and add/remove classesThoughts?
The text was updated successfully, but these errors were encountered: