1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

support IntersectionObserver

This commit is contained in:
Luke Pulverenti 2016-05-19 10:37:59 -04:00
parent 2d62dc8dd9
commit 48058e8fff
8 changed files with 135 additions and 62 deletions

View file

@ -16,12 +16,12 @@
}, },
"devDependencies": {}, "devDependencies": {},
"ignore": [], "ignore": [],
"version": "1.3.45", "version": "1.3.48",
"_release": "1.3.45", "_release": "1.3.48",
"_resolution": { "_resolution": {
"type": "version", "type": "version",
"tag": "1.3.45", "tag": "1.3.48",
"commit": "dbaa46e3aa38a939b82f305c61e875e1a30da2fe" "commit": "0764e35340e4625a5af560b2f46468646a7d9d10"
}, },
"_source": "https://github.com/MediaBrowser/emby-webcomponents.git", "_source": "https://github.com/MediaBrowser/emby-webcomponents.git",
"_target": "^1.2.0", "_target": "^1.2.0",

View file

@ -88,12 +88,48 @@ define(['visibleinviewport', 'imageFetcher', 'layoutManager', 'events'], functio
target.addEventListener(type, handler, optionsOrCapture); target.addEventListener(type, handler, optionsOrCapture);
} }
function unveilWithIntersection(images) {
var filledCount = 0;
var observer = new IntersectionObserver(function (entries) {
for (var j = 0, length2 = entries.length; j < length2; j++) {
var entry = entries[j];
var intersectionRatio = entry.intersectionRatio;
if (intersectionRatio) {
var target = entry.target;
observer.unobserve(target);
fillImage(target);
filledCount++;
}
}
if (filledCount >= images.length) {
//observer.disconnect();
}
},
{
/* Using default options. Details below */
}
);
// Start observing an element
for (var i = 0, length = images.length; i < length; i++) {
observer.observe(images[i]);
}
}
function unveilElements(images) { function unveilElements(images) {
if (!images.length) { if (!images.length) {
return; return;
} }
if (window.IntersectionObserver) {
unveilWithIntersection(images);
return;
}
var filledImages = []; var filledImages = [];
var cancellationTokens = []; var cancellationTokens = [];

View file

@ -11,7 +11,14 @@ define(['apphost', 'globalize', 'connectionManager'], function (appHost, globali
var commands = []; var commands = [];
if (item.CanDownload && user.Policy.EnableContentDownloading && appHost.supports('filedownload')) { if (item.CanDelete) {
commands.push({
name: globalize.translate('sharedcomponents#Delete'),
id: 'delete'
});
}
if (item.CanDownload && appHost.supports('filedownload')) {
commands.push({ commands.push({
name: globalize.translate('sharedcomponents#Download'), name: globalize.translate('sharedcomponents#Download'),
id: 'download' id: 'download'
@ -69,6 +76,14 @@ define(['apphost', 'globalize', 'connectionManager'], function (appHost, globali
case 'refresh': case 'refresh':
{ {
refresh(apiClient, itemId); refresh(apiClient, itemId);
reject();
break;
}
case 'delete':
{
deleteItem(apiClient, itemId).then(function () {
resolve(true);
});
break; break;
} }
case 'share': case 'share':
@ -83,11 +98,33 @@ define(['apphost', 'globalize', 'connectionManager'], function (appHost, globali
break; break;
} }
default: default:
reject();
break; break;
} }
}); });
} }
function deleteItem(apiClient, itemId) {
return new Promise(function (resolve, reject) {
var msg = globalize.translate('sharedcomponents#ConfirmDeleteItem');
var title = globalize.translate('sharedcomponents#HeaderDeleteItem');
require(['confirm'], function (confirm) {
confirm(msg, title).then(function () {
apiClient.deleteItem(itemId).then(function () {
resolve(true);
});
}, reject);
});
});
}
function refresh(apiClient, itemId) { function refresh(apiClient, itemId) {
apiClient.refreshItem(itemId, { apiClient.refreshItem(itemId, {
@ -97,7 +134,6 @@ define(['apphost', 'globalize', 'connectionManager'], function (appHost, globali
MetadataRefreshMode: 'FullRefresh', MetadataRefreshMode: 'FullRefresh',
ReplaceAllImages: false, ReplaceAllImages: false,
ReplaceAllMetadata: true ReplaceAllMetadata: true
}); });
require(['toast'], function (toast) { require(['toast'], function (toast) {

View file

@ -203,10 +203,10 @@ define(['loading', 'viewManager', 'skinManager', 'pluginManager', 'backdrop', 'b
if (!isBackNav) { if (!isBackNav) {
// Don't force a new view for home due to the back menu // Don't force a new view for home due to the back menu
if (route.type != 'home') { //if (route.type != 'home') {
onNewViewNeeded(); onNewViewNeeded();
return; return;
} //}
} }
viewManager.tryRestoreView(currentRequest).then(function () { viewManager.tryRestoreView(currentRequest).then(function () {

View file

@ -50,6 +50,9 @@
"Edit": "Edit", "Edit": "Edit",
"Download": "Download", "Download": "Download",
"Advanced": "Advanced", "Advanced": "Advanced",
"Delete": "Delete",
"HeaderDeleteItem": "Delete Item",
"ConfirmDeleteItem": "Deleting this item will delete it from both the file system and your media library. Are you sure you wish to continue?",
"Refresh": "Refresh", "Refresh": "Refresh",
"RefreshQueued": "Refresh queued." "RefreshQueued": "Refresh queued."
} }

View file

@ -112,76 +112,74 @@ define(['browser'], function (browser) {
function slide(newAnimatedPage, oldAnimatedPage, transition, isBack) { function slide(newAnimatedPage, oldAnimatedPage, transition, isBack) {
var timings = { return new Promise(function (resolve, reject) {
duration: 450, var timings = {
iterations: 1, duration: 450,
easing: 'ease-out', iterations: 1,
fill: 'both' easing: 'ease-out'
} }
var animations = []; var animations = [];
if (oldAnimatedPage) { if (oldAnimatedPage) {
var destination = isBack ? '100%' : '-100%'; var destination = isBack ? '100%' : '-100%';
animations.push(oldAnimatedPage.animate([ animations.push(oldAnimatedPage.animate([
{ transform: 'none', offset: 0 }, { transform: 'none', offset: 0 },
{ transform: 'translate3d(' + destination + ', 0, 0)', offset: 1 } { transform: 'translate3d(' + destination + ', 0, 0)', offset: 1 }
], timings));
}
newAnimatedPage.classList.remove('hide');
var start = isBack ? '-100%' : '100%';
animations.push(newAnimatedPage.animate([
{ transform: 'translate3d(' + start + ', 0, 0)', offset: 0 },
{ transform: 'none', offset: 1 }
], timings)); ], timings));
}
newAnimatedPage.classList.remove('hide'); currentAnimations = animations;
var start = isBack ? '-100%' : '100%';
animations.push(newAnimatedPage.animate([
{ transform: 'translate3d(' + start + ', 0, 0)', offset: 0 },
{ transform: 'none', offset: 1 }
], timings));
currentAnimations = animations;
return new Promise(function (resolve, reject) {
animations[animations.length - 1].onfinish = resolve; animations[animations.length - 1].onfinish = resolve;
}); });
} }
function fade(newAnimatedPage, oldAnimatedPage, transition, isBack) { function fade(newAnimatedPage, oldAnimatedPage, transition, isBack) {
var timings = { return new Promise(function (resolve, reject) {
duration: 200, var timings = {
iterations: 1, duration: 200,
easing: 'ease-out', iterations: 1,
fill: 'both' easing: 'ease-out'
} }
var animations = []; var animations = [];
if (oldAnimatedPage) { if (oldAnimatedPage) {
animations.push(oldAnimatedPage.animate([ animations.push(oldAnimatedPage.animate([
{ opacity: 1, offset: 0 }, { opacity: 1, offset: 0 },
{ opacity: 0, offset: 1 } { opacity: 0, offset: 1 }
], timings));
}
newAnimatedPage.classList.remove('hide');
animations.push(newAnimatedPage.animate([
{ opacity: 0, offset: 0 },
{ opacity: 1, offset: 1 }
], timings)); ], timings));
}
newAnimatedPage.classList.remove('hide'); currentAnimations = animations;
animations.push(newAnimatedPage.animate([
{ opacity: 0, offset: 0 },
{ opacity: 1, offset: 1 }
], timings));
currentAnimations = animations;
return new Promise(function (resolve, reject) {
animations[animations.length - 1].onfinish = resolve; animations[animations.length - 1].onfinish = resolve;
}); });
} }

View file

@ -30,14 +30,14 @@
"web-component-tester": "polymer/web-component-tester#^3.4.0" "web-component-tester": "polymer/web-component-tester#^3.4.0"
}, },
"ignore": [], "ignore": [],
"homepage": "https://github.com/polymerelements/iron-a11y-announcer", "homepage": "https://github.com/PolymerElements/iron-a11y-announcer",
"_release": "1.0.4", "_release": "1.0.4",
"_resolution": { "_resolution": {
"type": "version", "type": "version",
"tag": "v1.0.4", "tag": "v1.0.4",
"commit": "5ce3eb8c4282bb53cd72e348858dc6be6b4c50b9" "commit": "5ce3eb8c4282bb53cd72e348858dc6be6b4c50b9"
}, },
"_source": "git://github.com/polymerelements/iron-a11y-announcer.git", "_source": "git://github.com/PolymerElements/iron-a11y-announcer.git",
"_target": "^1.0.0", "_target": "^1.0.0",
"_originalSource": "polymerelements/iron-a11y-announcer" "_originalSource": "PolymerElements/iron-a11y-announcer"
} }

View file

@ -36,7 +36,7 @@
"tag": "v1.5.2", "tag": "v1.5.2",
"commit": "18e8e12dcd9a4560de480562f65935feed334b86" "commit": "18e8e12dcd9a4560de480562f65935feed334b86"
}, },
"_source": "git://github.com/PolymerElements/iron-selector.git", "_source": "git://github.com/polymerelements/iron-selector.git",
"_target": "^1.0.0", "_target": "^1.0.0",
"_originalSource": "PolymerElements/iron-selector" "_originalSource": "polymerelements/iron-selector"
} }