mirror of
https://github.com/24eme/signaturepdf
synced 2026-03-14 13:55:44 +01:00
flatten: return true early when rect found
We don't need to iterate on all objects if one rect is found
This commit is contained in:
parent
8234926d1e
commit
f577c68755
1 changed files with 6 additions and 6 deletions
|
|
@ -476,13 +476,13 @@ function addObjectInCanvas(canvas, item) {
|
|||
|
||||
function updateFlatten() {
|
||||
let flatten = Boolean(document.querySelector('input[name=watermark]').value);
|
||||
canvasEditions.forEach(function(canvasEdition, index) {
|
||||
canvasEdition.getObjects().forEach(function(object) {
|
||||
if(object.type == "rect") {
|
||||
flatten = true;
|
||||
}
|
||||
});
|
||||
|
||||
flatten = flatten || canvasEditions.some(function (canvas) {
|
||||
return canvas.getObjects().some(function (object) {
|
||||
return object.type === "rect"
|
||||
})
|
||||
})
|
||||
|
||||
document.querySelector('input[name=flatten]').checked = flatten;
|
||||
if(document.getElementById('save_flatten_indicator')) {
|
||||
document.getElementById('save_flatten_indicator').classList.toggle('invisible', !flatten);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue