应用过滤器时显示加载屏幕

编程入门 行业动态 更新时间:2024-10-18 16:54:00
本文介绍了应用过滤器时显示加载屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

将过滤器应用于占据整个画布的图像对象可能需要几秒钟的时间才能处理较大的图像,我想在此过程中显示加载屏幕,但是.show()方法要等到过滤器打开后才会触发已应用.

Applying a filter to an image object that occupies the whole canvas can take a couple seconds with larger images and I want to display a loading screen while this is happening but the .show() method isn't firing until after the filter has been applied.

应用过滤器的当前方法:

Current method that applies the filter:

applyFilter: function (index, filter) { var obj = designer.baseImage, $loading = $('#loading-canvas'); console.log('show loading'); $loading.show(); obj.filters[index] = filter; obj.applyFilters(function () { console.log('hide loading'); $loading.hide(); designer.canvas.renderAll(); }); }

调用该方法(单击)时,显示加载"将立即记录到控制台.在应用过滤器之前,不会显示加载div,此时加载屏幕将闪烁,消失,并将隐藏加载"记录到控制台.有什么想法为什么在将显示加载"记录到控制台后为何不显示加载屏幕?

When the method is called (on click) 'show loading' is logged to the console immediately. The loading div is not displayed until the filter has been applied, at which point the loading screen flashes up, goes away, and 'hide loading' is logged to the console. Any ideas why the loading screen isn't displayed when 'show loading' is logged to the console?

加载屏幕的唯一目的是向用户指示正在发生的事情

The loading screen's sole purpose so to indicate to the user that something is happening

推荐答案

@ A.Wolff非常接近,但似乎是时间问题?这是我的解决方案:

@A.Wolff was super close but it appeared to be a timing issue? Here's my solution:

applyFilter: function (index, filter) { var obj = designer.baseImage, $loading = $('#loading-canvas'); $loading.show('slow', function () { obj.filters[index] = filter; obj.applyFilters(function () { $loading.hide(); designer.canvas.renderAll(); }); }); }

原始解决方案不适用于show()的第一个参数为0的情况,不能与快速"一起使用,而与慢速"一起使用则完美.

The original solution didn't work with show()'s first argument being 0, worked better with 'fast' and works perfectly with 'slow'.

更多推荐

应用过滤器时显示加载屏幕

本文发布于:2023-11-22 20:29:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1618911.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:过滤器   加载   屏幕

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!