Preload photo on mouseover
This commit is contained in:
parent
72b7beaa31
commit
7ba869b5a3
@ -2810,9 +2810,8 @@ factory('MtpApiFileManager', function (MtpApiManager, $q, $window) {
|
|||||||
cacheFileWriter = fileWriter;
|
cacheFileWriter = fileWriter;
|
||||||
// console.time(fileName + ' ' + (size / 1024));
|
// console.time(fileName + ' ' + (size / 1024));
|
||||||
|
|
||||||
// var limit = size > 102400 ? 65536 : 4096;
|
var limit = 524288;
|
||||||
var limit = size > 30400 ? 524288 : 4096;
|
// var limit = size > 16384 ? 524288 : 51200;
|
||||||
// var limit = size > 30400 ? 50480 : 4096;
|
|
||||||
var writeFilePromise = $q.when(),
|
var writeFilePromise = $q.when(),
|
||||||
writeFileDeferred;
|
writeFileDeferred;
|
||||||
for (var offset = 0; offset < size; offset += limit) {
|
for (var offset = 0; offset < size; offset += limit) {
|
||||||
|
@ -1880,6 +1880,31 @@ angular.module('myApp.services', [])
|
|||||||
return photo;
|
return photo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function preloadPhoto (photoID) {
|
||||||
|
if (!photos[photoID]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var photo = photos[photoID],
|
||||||
|
fullWidth = $(window).width() - 36,
|
||||||
|
fullHeight = $($window).height() - 150,
|
||||||
|
fullPhotoSize = choosePhotoSize(photo, fullWidth, fullHeight);
|
||||||
|
|
||||||
|
if (fullPhotoSize && !fullPhotoSize.preloaded) {
|
||||||
|
fullPhotoSize.preloaded = true;
|
||||||
|
if (fullPhotoSize.size) {
|
||||||
|
MtpApiFileManager.downloadFile(fullPhotoSize.location.dc_id, {
|
||||||
|
_: 'inputFileLocation',
|
||||||
|
volume_id: fullPhotoSize.location.volume_id,
|
||||||
|
local_id: fullPhotoSize.location.local_id,
|
||||||
|
secret: fullPhotoSize.location.secret
|
||||||
|
}, fullPhotoSize.size);
|
||||||
|
} else {
|
||||||
|
MtpApiFileManager.downloadSmallFile(fullPhotoSize.location);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
$rootScope.preloadPhoto = preloadPhoto;
|
||||||
|
|
||||||
function wrapForFull (photoID) {
|
function wrapForFull (photoID) {
|
||||||
var photo = wrapForHistory(photoID),
|
var photo = wrapForHistory(photoID),
|
||||||
fullWidth = $(window).width() - 36,
|
fullWidth = $(window).width() - 36,
|
||||||
@ -1940,6 +1965,7 @@ angular.module('myApp.services', [])
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
savePhoto: savePhoto,
|
savePhoto: savePhoto,
|
||||||
|
preloadPhoto: preloadPhoto,
|
||||||
wrapForHistory: wrapForHistory,
|
wrapForHistory: wrapForHistory,
|
||||||
wrapForFull: wrapForFull,
|
wrapForFull: wrapForFull,
|
||||||
openPhoto: openPhoto
|
openPhoto: openPhoto
|
||||||
|
@ -96,7 +96,7 @@
|
|||||||
|
|
||||||
<div bo-if="historyMessage.media && historyMessage.media._ != 'messageMediaEmpty'" class="im_message_media" ng-switch="historyMessage.media._">
|
<div bo-if="historyMessage.media && historyMessage.media._ != 'messageMediaEmpty'" class="im_message_media" ng-switch="historyMessage.media._">
|
||||||
|
|
||||||
<a ng-switch-when="messageMediaPhoto" class="im_message_photo_thumb" href="" ng-click="openPhoto(historyMessage.media.photo.id)" style="width: {{historyMessage.media.photo.thumb.width}}px;">
|
<a ng-switch-when="messageMediaPhoto" class="im_message_photo_thumb" href="" ng-click="openPhoto(historyMessage.media.photo.id)" style="width: {{historyMessage.media.photo.thumb.width}}px;" ng-mouseover="preloadPhoto(historyMessage.media.photo.id)">
|
||||||
<img
|
<img
|
||||||
class="im_message_photo_thumb"
|
class="im_message_photo_thumb"
|
||||||
my-load-thumb
|
my-load-thumb
|
||||||
|
Loading…
Reference in New Issue
Block a user