Skip to content

Commit

Permalink
preview optimization (#1573)
Browse files Browse the repository at this point in the history
Co-authored-by: Rishabh Shukla <42492389+blurry-x-face@users.noreply.github.com>
Co-authored-by: Jeffrey Warren <jeff@unterbahn.com>
  • Loading branch information
3 people authored Jan 29, 2020
1 parent 28cedd7 commit 5f745ef
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions examples/lib/defaultHtmlSequencerUi.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var urlHash = require('./urlHash.js');
insertPreview = require('./insertPreview.js');
function DefaultHtmlSequencerUi(_sequencer, options) {

options = options || {};
Expand Down Expand Up @@ -33,6 +34,11 @@ function DefaultHtmlSequencerUi(_sequencer, options) {

function removeStepUi() {
var index = $(removeStepSel).index(this) + 1;
// If last step is removed.
if(sequencer.steps.length==index+1){
console.log("inside")
insertPreview.updatePreviews(sequencer.steps[index-1].output.src, document.querySelector('#addStep'));
}
sequencer.removeSteps(index).run({ index: index - 1 });
// remove from URL hash too
urlHash.setUrlHashParameter('steps', sequencer.toString());
Expand Down
4 changes: 4 additions & 0 deletions examples/lib/defaultHtmlStepUi.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
const intermediateHtmlStepUi = require('./intermediateHtmlStepUi.js'),
urlHash = require('./urlHash.js'),
_ = require('lodash'),
insertPreview = require('./insertPreview.js');
mapHtmlTypes = require('./mapHtmltypes'),
scopeQuery = require('./scopeQuery'),
isGIF = require('../../src/util/isGif');
Expand Down Expand Up @@ -365,6 +366,9 @@ function DefaultHtmlStepUi(_sequencer, options) {
updateDimensions(step);
});

if (step.name === 'load-image') insertPreview.updatePreviews(step.output.src, document.querySelector('#addStep'));
else insertPreview.updatePreviews(step.output, document.querySelector('#addStep'));

// Handle the wasm bolt display

if (step.useWasm) {
Expand Down
1 change: 1 addition & 0 deletions examples/lib/insertPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function generatePreview(previewStepName, customValues, path, DomNode) {
$(img).css('transform', 'translateX(-20%)');
$(DomNode.querySelector('.radio-group')).find('.radio').each(function() {
if ($(this).attr('data-value') === previewStepName) {
$(this).find('img').remove();
$(this).append(img);
}
});
Expand Down

0 comments on commit 5f745ef

Please sign in to comment.