ziad-saab / hw-parallax

Hardware-accelerated parallax scrolling plugin for jQuery
MIT License
39 stars 13 forks source link

New 'image_attr' option #3

Closed markchitty closed 10 years ago

markchitty commented 10 years ago

Allows alternative 'data-image-mobile' attribute to be specified for loading mobile optimised images:

HTML
<div data-image="image_source_relative_to_page" data-image-mobile="mobile_image_source"
data-width="image_width_in_pixels" data-height="image_height_in_pixels">

The data-wdith and data-height attributes still refer to the main full-size image and don't need repeating as they're only used to calculate the image aspect-ratio.

JavaScript

To use this option, specify which image_attr to use when initialising parallax().

var touch = Modernizr.touch;
$('.parallax').parallax({
  image_attr: (touch) ? 'image-mobile' : 'image',
  scroll_factor: 0.5
});

Attribution: idea and implementation lifted pretty much wholesale from https://github.com/pederan/Parallax-ImageScroll.

ziad-saab commented 10 years ago

:+1: