BiMap, jQuery breakpoint

Original author: Alex Young
  • Transfer

Bimap


BiMap (GitHub: alethes / bimap , License: MIT , npm: bimap ) by James Daab is a bi-directional implementation of a data structure such as a map. This implementation allows you to access the value through the keys and vice versa to the keys through the values:
bimap.push({
  a: {
    b: 1,
    c: {
      d: 2
    }
  }
});
bimap.key('a.b'); // => 1
bimap.val(2); // => "a.c.d"

jQuery breakpoint


jQuery breakpoint (GitHub: joshbambrick / breakpoint , License: MIT ) by Joshua Bambrick is an extension that responds to page resizing. This is an ideal solution if you need to respond from JavaScript to page resizing when working with responsive design.

You can attach processors to $.breakpoint.on, which is also capable of receiving an array, in order to respond to various, predefined, device sizes (resolutions). Also, it is available $.breakpoint.offfor removing handlers and $.breakpoint.changeBreakpointsfor changing globally recognized (established) sizes (permissions) of devices.

$ .breakpoint.on

var makeChanges = function (breakpointName) {
    if (breakpointName === 'palm') {
        // make changes for mobile
    } else if (breakpointName === 'lap') {
        // make changes for small screen width
    } else {
        // `breakpointName` is 'default' as the new page width matches neither 'palm' nor 'lap'
    }
};
$.breakpoint.on(['palm', 'lap'], makeChanges);

$ .breakpoint.off

$.breakpoint.off(makeChanges);

$ .breakpoint.changeBreakpoints

{
    palm: {
        max: 719
    },
    lap: {
        max: 1023,
        min: 720
    },
    'lap-and-up': {
        min: 720
    },
    portable: {
        max: 1023
    },
    desk: {
        min: 1024
    }
}

Also popular now: