Small Snippet for Pinterest

Discussion in 'Scripts' started by notarypublic, Mar 5, 2013.

to remove all ads.
  1. notarypublic

    notarypublic New Member

    Messages:
    235
    This only works in Firefox so far, but I've written a small JS snippet to make navigating between pins easier (using left and right arrow keys, when one pin is opened inside of a lightbox)

    Code:
     $(document).on('keypress', function(e) {
    if ($('#zoomScroll').length){
    //get the appropriate pins
    var currentPin = $('#zoom').attr('pin-id');
    var currentPinElement = $('#ColumnContainer').find('[data-id="'+currentPin+'"]').first();
    var newPin = false;
    
    if(e.keyCode==37){
    //left
    var previousPin = $(currentPinElement).prev();
    console.log('previousPin', previousPin);
    if ($(previousPin).attr('data-id')){
    $('#zoomScroll').trigger('click');
    $(currentPinElement).prev().find('.PinImage').trigger('click');
    console.log('left.');
    newPin = true;
    }
    }
    else if (e.keyCode==39){
    //right
    var nextPin = $(currentPinElement).next();
    if (nextPin.attr('data-id')){
    $('#zoomScroll').trigger('click');
    $(currentPinElement).next().find('.PinImage').trigger('click');
    newPin = true;
    }
    }
    
    if (newPin === true){
    $('html, body').animate({
    scrollTop: currentPinElement.offset().top
    }, 0);
    }
    
    }
    }); 
    
     
  2. notarypublic

    notarypublic New Member

    Messages:
    235
    Any idea how to make this a plugin for the browser?
     

Share This Page