kthornbloom / Smoothproducts

A simple, lightweight and responsive product image viewer using jQuery
kthornbloom.com/smoothproducts
185 stars 89 forks source link

Smoothproducts

A lightweight & simple jQuery product viewer script

Features

Usage

<link rel="stylesheet" href="https://github.com/kthornbloom/Smoothproducts/blob/master/css/smoothproducts.css">
<script type="text/javascript" src="https://github.com/kthornbloom/Smoothproducts/raw/master/js/smoothproducts.min.js"></script>
<script type="text/javascript">
    /* wait for images to load */
    $(window).load( function() {
        $('.sp-wrap').smoothproducts();
    });
</script>
<div class="sp-wrap">
    <a href="https://github.com/kthornbloom/Smoothproducts/blob/master/images/1.jpg"><img src="https://github.com/kthornbloom/Smoothproducts/raw/master/images/1_tb.jpg" alt=""></a>
    <a href="https://github.com/kthornbloom/Smoothproducts/blob/master/images/2.jpg"><img src="https://github.com/kthornbloom/Smoothproducts/raw/master/images/2_tb.jpg" alt=""></a>
</div>
<div class="sp-loading"><img src="https://github.com/kthornbloom/Smoothproducts/raw/master/images/sp-loading.gif" alt=""><br>LOADING IMAGES</div>
<div class="sp-wrap">
    <a href="https://github.com/kthornbloom/Smoothproducts/blob/master/images/1.jpg"><img src="https://github.com/kthornbloom/Smoothproducts/raw/master/images/1_tb.jpg" alt=""></a>
    <a href="https://github.com/kthornbloom/Smoothproducts/blob/master/images/2.jpg"><img src="https://github.com/kthornbloom/Smoothproducts/raw/master/images/2_tb.jpg" alt=""></a>
</div>
    .sp-wrap {
        max-width: 300px;
    }
<div class="sp-wrap">
    <a href="https://github.com/kthornbloom/Smoothproducts/blob/master/images/1.jpg"><img src="https://github.com/kthornbloom/Smoothproducts/raw/master/images/1_tb.jpg" alt=""></a>
    <a href="https://github.com/kthornbloom/Smoothproducts/blob/master/images/2.jpg" class="sp-default"><img src="https://github.com/kthornbloom/Smoothproducts/raw/master/images/2_tb.jpg" alt=""></a>
</div>

AngularJS

<div class="sp-wrap">
    <a href="https://github.com/kthornbloom/Smoothproducts/blob/master/{{image.url}}" ng-repeat="image in images track by $index"><img src="https://github.com/kthornbloom/Smoothproducts/raw/master/{{image.tb.url}}" alt=""></a>
    <div ng-if="$last" activate_photos></div>
</div>
app.directive('activatePhotos', [
'timeout', function(timeout) {
    return {
        restrict: 'A',
        link: function(scope, elem, attr) {
            return timeout(function() {
                $('.sp-wrap').deleteSmoothProducts(); //clear previous event listeners
                $('.sp-wrap').smoothproducts();
            });
        }
    };
}
]);

Plugins

A Rails plugin providing the necessary files is available here.

Licensing

Free to use and modify personally or commercially. Not for resale.