Responsively move elements to different locations based on width breakpoints. Re-written using ES6 and compiled/bundled using rollup.js.
- Clone the repository.
- Run
npm install && npm run dev
. - Have fun and submit a PR!
$('#content .desc').move({
breakpoint: 1000,
oldLocation: '#content .container',
newLocation: '#content h2',
onMove: function(method, element) {
if (method == 'oldLocation') {
console.log('Moved back!');
}
if (method == 'newLocation') {
console.log('Moved to new location!');
}
},
methods: {
o: 'appendTo',
n: 'insertAfter'
}
});
Your width based breakpoint, eg. 1000
.
Default: null
The old location for the element to be moved back to. eg #content .container
.
Default: null
The new location for the element to be moved to. eg #content
.
Default: null
Callback function for when an element is moved. Returned parameters are the method to move, ie newLocation
or oldLocation
, and the element that was moved. eg. function(method, element) {}
.
Default: null
The methods jQuery will use for handling moving your element around the DOM.
methods: {
o: 'appendTo',
n: 'insertAfter'
}
Default for both o
and n
: appendTo, where o
is the method for moving the element back to it's oldLocation, and n
is the method for moving the element into it's newLocation.
Valid properties: appendTo, prependTo, insertAfter, and insertBefore