orion3dgames / gridder

A jQuery plugin that displays a thumbnail grid expanding preview similar to the effect seen on Google Images.
http://orion3dgames.github.io/gridder/
461 stars 130 forks source link

Hot linking update? #37

Open FlipperPA opened 8 years ago

FlipperPA commented 8 years ago

I noticed hot linking as a To-Do list item, and this is a feature I'd love. I tried tinkering myself but have run into a brick wall.

I've got it so it'll auto-pop the gridder panel open by doing the following:

$(window).load(function() {
  index_position = document.URL.indexOf("#");
  if(index_position != -1) {
    anchor_name = document.URL.substring(index_position);
    $(anchor_name).trigger("click");
  }
});

Basically, I pass in the div ID of the item to be expanded as an anchor name in the URL and simulate a click of that panel after the Window has fully loaded. $(window).load occurs after all document ready jQuery functions complete. This works great, however, when I try to mix in a scroll-to, it can't navigate to the proper location on the page, as it is being "painted" in the browser dynamically.

Am I barking up the wrong tree? Did you have an ideas on how to get this working? I've tried a bunch of things and am now beating my head against the wall instead of issuing a useful P.R. :) Thanks for your work on a great plugin!

orion3dgames commented 8 years ago

Hello,

Yes, I need to implement it. Too busy at the moment.

To reply to you question, I've not really thought about it.

Your code looks great, except you should not need to add any scrolling, the gridder plugin should scroll automatically to the correct item... Do you have a link I can test?

If you need real url hot link, why not use the other version of gridder I have ( It's a little messy, but works fine once configured correctly ) : https://github.com/oriongunning/gridder-ajax

Some people struggle to get it working, but if you familiar with how servers work, you will be fine.

Regards, Orion

intellisense commented 8 years ago

@FlipperPA What you are doing is right, but you should do it after the gridder has been initialized e.g. with in onStart and you don't need to add any manual scrolling code:

    $(".gridder").gridderExpander({
        // other options
        onStart: function () {
            index_position = document.URL.indexOf("#");
            if(index_position != -1) {
               anchor_name = document.URL.substring(index_position);
               $(anchor_name).trigger("click");
            }
        },
    });
orion3dgames commented 6 years ago

That's exactly it. Thanks @intellisense

ddaydd commented 6 years ago

T'as pris une année sabbatique ou quoi? :p