A small helper module to provide convinience methods
If you one of those jQuery users who only use this framework for some convinience methods and totaly aware of the fact that there is no need to use jQuery only for creating selectors, than imxQuery might come in handy.
Currently there is only one way to install the CSS3Slider, using NPM:
$ npm install imxquery
After this you can simply require imxQuery:
var imxQuery = require('imxquery');
imxQuery down to the base, is a simple VanilaJS module. You can access it through several public methds:
offsetTop will return you the top offset of a given node relative to the body
imxQuery.offsetTop(htmlNode);
offsetTop will return you the left offset of a given node relative to the body
imxQuery.offsetLeft(htmlNode);
scrollTo will scroll the window to a specific position.
imxQuery.scrollTo(xPosition, yPosition, duration);
- xPosition - target position on the x-axis
- yPosition - target position on the y-axis
- duration - amount of time it shall need, for the scroll to perform
In order to scroll to a specific node on the page, you can combine the offset methods with the scroll method:
imxQuery.scrollTo(0, imxQuery.offsetTop(htmlNode), 100);
The same as scrollTo, but scrolls inside an element.
imxQuery.scrollElementTo(xPosition, yPosition, duration, targetNode);
- targetNode - the htmlNode that you want to scroll
A handy small wrapper method to read out data attributes
<article id="myTestArticle" data-info_latitude="54.756">
imxQuery.accessDataset(document.getElementById('myTestArticle'), 'info_latitude');
Extend an object with another object, adding missing fields
var baseObject = {
title : 'title text',
text : 'a lot of text'
};
var configObject = {
lat : '54.765',
lng : '7.897'
};
imxQuery.extendObject(baseObject, configObject);
This will result in:
var baseObject = {
title : 'title text',
text : 'a lot of text',
lat : '54.765',
lng : '7.897'
};
Wait for the document to be loaded completly, to perform a callBack function.
imxQuery.documentReady(function(){
alert('document is loaded');
});