Browse Source

Preload photo on mouseover

master
Igor Zhukov 11 years ago
parent
commit
7ba869b5a3
  1. 5
      app/js/lib/mtproto.js
  2. 26
      app/js/services.js
  3. 2
      app/partials/message.html

5
app/js/lib/mtproto.js

@ -2810,9 +2810,8 @@ factory('MtpApiFileManager', function (MtpApiManager, $q, $window) { @@ -2810,9 +2810,8 @@ factory('MtpApiFileManager', function (MtpApiManager, $q, $window) {
cacheFileWriter = fileWriter;
// console.time(fileName + ' ' + (size / 1024));
// var limit = size > 102400 ? 65536 : 4096;
var limit = size > 30400 ? 524288 : 4096;
// var limit = size > 30400 ? 50480 : 4096;
var limit = 524288;
// var limit = size > 16384 ? 524288 : 51200;
var writeFilePromise = $q.when(),
writeFileDeferred;
for (var offset = 0; offset < size; offset += limit) {

26
app/js/services.js

@ -1880,6 +1880,31 @@ angular.module('myApp.services', []) @@ -1880,6 +1880,31 @@ angular.module('myApp.services', [])
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) {
var photo = wrapForHistory(photoID),
fullWidth = $(window).width() - 36,
@ -1940,6 +1965,7 @@ angular.module('myApp.services', []) @@ -1940,6 +1965,7 @@ angular.module('myApp.services', [])
return {
savePhoto: savePhoto,
preloadPhoto: preloadPhoto,
wrapForHistory: wrapForHistory,
wrapForFull: wrapForFull,
openPhoto: openPhoto

2
app/partials/message.html

@ -96,7 +96,7 @@ @@ -96,7 +96,7 @@
<div bo-if="historyMessage.media &amp;&amp; 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
class="im_message_photo_thumb"
my-load-thumb

Loading…
Cancel
Save