-
Improvement
-
Resolution: Unresolved
-
Major
-
1.7.0
-
None
-
1 - Middle term
-
2 - Normal
- Add jQuery plugin Waypoints (4.0 or more) : https://github.com/imakewebthings/waypoints
- Add call to this plugin in common-service-head-js of youtubegallery_1.4.xsl:
<script type="text/javascript" src="{ametys:pluginResourceURL('inlinemedia', 'js/jquery.waypoints.min.js')}"/>
- And add a div for lazy loading after playlist_{$uniqueId} <ul>:
<div id="playlist_{$uniqueId}_lazyload" style="text-align:center;"><img width="50" height="50" src="{ametys:pluginResourceURL('inlinemedia', 'img/loading.gif')}"/></div>
- Modify addVideos javascript function (playlist.js) by replacing :
if (data.nextPageToken) { addVideos (uniqueId, playlistId, apiKey, data.nextPageToken); }
by:
if (data.nextPageToken) { $j('#playlist_' + playlistUniqueId + '_lazyload').show(); new Waypoint({ element: document.getElementById('playlist_' + playlistUniqueId + '_lazyload'), handler: function(direction) { if (direction == 'down') { addVideos(uniqueId, playlistId, apiKey, data.nextPageToken); this.destroy(); } }, offset: 'bottom-in-view' }); } else { $j('#playlist_' + playlistUniqueId + '_lazyload').hide(); }