From 9e71da0f4ea3ea310260e70bf11d8b93dd27f55a Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sun, 16 Apr 2017 18:35:28 +0300 Subject: [PATCH] started work on new ribbon update strategy... Signed-off-by: Alex A. Naanou --- ui (gen4)/imagegrid/ribbons.js | 42 ++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/ui (gen4)/imagegrid/ribbons.js b/ui (gen4)/imagegrid/ribbons.js index 5d607620..be7eadbf 100755 --- a/ui (gen4)/imagegrid/ribbons.js +++ b/ui (gen4)/imagegrid/ribbons.js @@ -1525,8 +1525,6 @@ var RibbonsPrototype = { // get/create the ribbon... var r = this.getRibbon(ribbon) - var W = Math.min(document.body.offsetWidth, document.body.offsetHeight) - if(r.length == 0){ place = true // no such ribbon exists, then create and append it in the end... @@ -1544,6 +1542,7 @@ var RibbonsPrototype = { // align only if ref is loaded... if(ref.length > 0){ var gid = this.getElemGID(ref) + var W = Math.min(document.body.offsetWidth, document.body.offsetHeight) var w = this.getVisibleImageSize('width', 1, ref) / W * 100 // calculate offset... @@ -1637,6 +1636,45 @@ var RibbonsPrototype = { return this }, + // NOTE: reference must be both present in the loaded ribbon and in + // the given gids... + updateRibbonInPlace: function(gids, ribbon, reference){ + var that = this + var r = this.getRibbon(ribbon) + var loaded = r.find(IMAGE) + + // update offset... + if(reference != null){ + var ref = this.getImage(reference) + + // align only if ref is loaded... + if(ref.length > 0){ + var gid = this.getElemGID(ref) + var W = Math.min(document.body.offsetWidth, document.body.offsetHeight) + var w = this.getVisibleImageSize('width', 1, ref) / W * 100 + + // calculate offset... + // NOTE: this will not work for non-square images... + var dl = loaded.index(ref) - gids.indexOf(gid) + + if(dl != 0){ + var x = parseFloat((r.transform('translate3d') || [0])[0]) + w * dl + r.transform({x: x + 'vmin', y: 0, z: 0}) + } + } + } + + // update gids... + $(gids.slice(0, loaded.length-1)) + .each(function(i, gid){ + gid && that.setElemGID(loaded.eq(i), gid) }) + + // update images... + this.updateImage(loaded) + + return this + }, + // Resize ribbon... // // .resizeRibbon(ribbon, left, right)