-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding Lazy Image Load for Icons #6692
Conversation
Can one of the admins verify this patch? |
@owncloud-bot ok to test |
@rnveach Thanks a lot for your contribution! Alternatively you can add a comment here where you state that this contribution is MIT licensed. Some more details about out pull request workflow can be found here: http://owncloud.org/code-reviews-on-github/ |
Quick test on chromium - awesome 👍 |
@@ -701,6 +701,8 @@ var FileList={ | |||
$connector.show(); | |||
} | |||
} | |||
|
|||
$(".lazy").lazyload(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you maybe restrict the jQuery selector to the file list ? This way it won't try to find the class in the whole page.
Something like $('#filesTable .lazy')
@rnveach nice one! Did you test it with file upload ? |
CC @owncloud/designers @georgehrke |
@PVince81 Perhaps not the right place to discuss this, but can a similar functionality be implemented for Gallery thumbnails as well as for public gallery sharing? Currently gallery loads every thumbnail in both views and it's unfortunate when you have many 100/1000s of images inside one folder. |
@fossxplorer good catch - THX - Can you open a ticket on the apps repo - just to make sure we don't forget? THX |
I updated the trashbin to also lazy load images since the same code was connected to the normal directory listing and there was an error before that I didn't notice. @PVince81 : I added the restricted selector. For the "jquery.lazyload.js" should we switch to the minified source? |
@rnveach thanks. Please leave the non-minified source for "jquery.lazyload.js". ownCloud has its own minifier when DEBUG mode is disabled. Having the real source makes it easier to debug in case of bugs 😄 |
And the unminified version has to be kept due to licensing. Von Samsung Mobile gesendet -------- Ursprüngliche Nachricht -------- @rnveach thanks. Please leave the non-minified source for "jquery.lazyload.js". ownCloud has its own minifier when DEBUG mode is disabled. Having the real source makes it easier to debug in case of bugs — |
@rnveach your pull request can no longer be merged - can I ask you to rebase your branch? Thanks a lot! |
I finished the rebase. All the code should be up. |
@@ -97,8 +100,9 @@ var FileList={ | |||
tr.append(td); | |||
return tr; | |||
}, | |||
addFile:function(name, size, lastModified, loading, hidden, param) { | |||
addFile:function(name, etag, size, lastModified, loading, hidden, param) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this, as it's changing the function's signature as other apps might be using it (not sure for what though).
Another idea would to pass it through the "param" attribute for now.
Do you mind changing this ? (minor)
Ideally I intend to change this method in OC7 to receive a hash array as single argument, where API changes are acceptable.
But in case we want to backport your fix to OC6 it would be safer to keep the function signature as is.
I tried the following steps:
|
The way the lazy load works is it creates an array of images on the page that it is to watch and maintain. With drag and drop, recalling the lazy load function doesn't remove the old array, so the library keeps trying to work with the old array even if the images aren't displayed on the page anymore. Atleast this is what I was seeing with FF. If this is still unacceptable, we can discuss this in IRC on a better way to deal with it.
|
@rnveach can you please state the license as requested in #6692 (comment) ? Thanks 😄 |
|
FileActions.display(tr.find('td.filename'), true); | ||
$('#fileList .lazy').lazyload(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think hee you only need to call lazyLoad()
on the tr instead of the whole list:
tr.lazyLoad()
This idea goes together with my comment about removeLazyLoad()
This should improve performance when the file list is very big.
Had a quick test in Chrome and it works well. |
Test failed. |
@rnveach can you please rebase this? THX |
@rnveach let me know if you need help for rebasing. |
A new inspection was created. |
This is not needed any more since the introduction of infinite scrolling on master, because it implicitly lazy loads previews by only rendering in a paginated manner. Closing now, thanks. |
This is my first fork and pull request, so I hope nothing is wrong with it.
I originally submitted a feature request for changing always loading file icon images to lazy loading them to save on bandwidth when opening a folder with many pictures inside it.
The original issue can be read here at #6591 and all my reasoning for the need of this addition.
I have made small changes to the owncloud's core app "files" that achieves this functionality and am submitting it here so hopefully it can be incorporated.
The main addition is the JQuery Lazy Load library that I found at http://www.appelsiini.net/projects/lazyload , which can be used, as is, with no modifications. The library is released under the MIT License, which I believe it compatible with owncloud's APGL. Correct me if I am wrong.
The main changes to the file listing is replacing the background image style for the icon and putting it into a custom attribute that Lazy Load recognizes and works with.
The only other change is the call to the Lazy Load function in JS to monitor the user scrolling and position in the document.
I have tested this with owncloud 6.0.0a and found no issues in IE8 and FF26. The images that are not in view don't load when opening a directory (verified with firebug's net panel), the images are loaded correctly when scrolled into view, and cached images still show up rather instantly. I didn't see any problems with applying the changes to the master in git.