图像调整大小需要很长时间,我实现了类似这样的东西来挂钩图像大小调整的开始和结束。
src / model.js:108我的补充是范围。$ emit ones
function handleFile(f, i) {
if (f.type.indexOf('image') === 0) {
if (param.pattern && !upload.validatePattern(f, param.pattern)) return;
scope.$emit('resizeStarted');
var promise = upload.resize(f, param.width, param.height, param.quality,
param.type, param.ratio, param.centerCrop, function (width, height) {
return upload.attrGetter('ngfResizeIf', attr, scope,
{$width: width, $height: height, $file: f});
}, param.restoreExif !== false);
promises.push(promise);
promise.then(function (resizedFile) {
scope.$emit('resizeFinished');
files.splice(i, 1, resizedFile);
}, function (e) {
scope.$emit('resizeFinished');
f.$error = 'resize';
f.$errorParam = (e ? (e.message ? e.message : e) + ': ' : '') + (f && f.name);
});
}
}
我想知道是否有更好的方法?