首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >下拉区域停止复选标记和错误图标从消失

问下拉区域停止复选标记和错误图标从消失
EN

Stack Overflow用户
提问于 2021-06-30 09:59:31
回答 1查看 579关注 0票数 1

这是我的当前配置:

代码语言:javascript
复制
var dropzone = new Dropzone("#dropzone",{
url: "<?php echo site_url($this->data['controller']."/Upload")?>",
params: {
    'transaction_id': "<?php echo $upload_transaction_id; ?>",
    '<?php echo $this->security->get_csrf_token_name();?>': '<?php echo $this->security->get_csrf_hash();?>'
},
acceptedFiles: "application/pdf",
init: function() {
    this.on("success", function(file, responseText) {
        $(".dz-success-mark svg").css("background", "green");
        $(".dz-error-mark").css("display", "none");
        $(".dz-success-mark svg").css('border-radius', '30px');
        $(".dz-success-mark").css("opacity","1");
        index++;
        console.log("Response Text: "+responseText);
        if(index===dropzone.files.length){
            count_uploaded_files(tid);
            $(".dz-hidden-input").prop("disabled",true);
            $('#ajax_success'). css('display','block');
            $('#ajax_success_content').html("Upload completed: "+dropzone.files.length+" files uploaded");
        }
    });
     this.on("error", function(file, responseText) {
      $(".dz-error-mark svg").css("background", "red");
      $(".dz-success-mark").css("display", "none");
        $(".dz-error-mark svg").css('border-radius', '30px')
        $(".dz-error-mark").css("opacity","1");
        console.log("Error");
    });
}

当文件上传成功后,会出现一个绿色的复选标记,并在几秒钟后消失。

当前的行为是在复选标记消失之后,由于不透明设置为1,将在我的文件上出现一个复选标记。然而,这将导致所有未上载的文件都有一个绿色的复选标记。

是否有一种方法来设置它,以便只有当前上传的文件显示绿色的复选标记,或者首先防止该复选标记消失?

EN

回答 1

Stack Overflow用户

发布于 2022-01-31 15:29:31

使用类.dz-success-mark的所有元素,并将不透明度设置为1到所有元素,因此它将无法工作。

您可以尝试使用这个SCSS覆盖标记的默认行为,它对我是有效的。

代码语言:javascript
复制
// Override the passing-through animation with my own custom passing-through-custom animation
.dropzone .dz-preview.dz-error .dz-error-mark {
    -webkit-animation: 3s cubic-bezier(0.77, 0, 0.175, 1) passing-through-custom !important;
    animation: 3s cubic-bezier(0.77, 0, 0.175, 1) passing-through-custom !important;
}
.dropzone .dz-preview.dz-success .dz-success-mark {
    -webkit-animation: 3s cubic-bezier(0.77, 0, 0.175, 1) passing-through-custom !important;
    animation: 3s cubic-bezier(0.77, 0, 0.175, 1) passing-through-custom !important;
}
// Set the opacity to 1 after upload completion/error (Dropzone js will put the class .dz-success or .error-mark on the .dz-preview)
.dropzone {
    .dz-preview.dz-error {
        .dz-error-mark{
            opacity: 1 !important;
        }
    }
    .dz-preview.dz-success {
        .dz-success-mark {
            opacity: 1 !important;
        }
    }
}
// From 0% to 70% nothing change from the original passing-through animation, but the 100% keyframe is mantaing the same value of the 70%, so the marker is not disappearing in this way

//Animation for all browser
@-webkit-keyframes passing-through-custom {
    0% {
        opacity: 0;
        -webkit-transform: translateY(40px);
        transform: translateY(40px);
    }
    30%, 70% {
        opacity: 1;
        -webkit-transform: translateY(0);
        transform: translateY(0);
    }
    100% {
        opacity: 1;
        -webkit-transform: translateY(0);
        transform: translateY(0);
    }
}
@-moz-keyframes passing-through-custom {
    0% {
        opacity: 0;
        -webkit-transform: translateY(40px);
        transform: translateY(40px);
    }
    30%, 70% {
        opacity: 1;
        -webkit-transform: translateY(0);
        transform: translateY(0);
    }
    100% {
        opacity: 1;
        -webkit-transform: translateY(0);
        transform: translateY(0);
    }
}
@keyframes passing-through-custom {
    0% {
        opacity: 0;
        -webkit-transform: translateY(40px);
        transform: translateY(40px);
    }
    30%, 70% {
        opacity: 1;
        -webkit-transform: translateY(0);
        transform: translateY(0);
    }
    100% {
        opacity: 1;
        -webkit-transform: translateY(0);
        transform: translateY(0);
    }
}

如果不使用SCSS,则使用CSS:

代码语言:javascript
复制
.dropzone .dz-preview.dz-error .dz-error-mark {
    -webkit-animation: 3s cubic-bezier(0.77, 0, 0.175, 1) passing-through-custom !important;
    animation: 3s cubic-bezier(0.77, 0, 0.175, 1) passing-through-custom !important;
}
.dropzone .dz-preview.dz-success .dz-success-mark {
    -webkit-animation: 3s cubic-bezier(0.77, 0, 0.175, 1) passing-through-custom !important;
    animation: 3s cubic-bezier(0.77, 0, 0.175, 1) passing-through-custom !important;
}
.dropzone .dz-preview.dz-error .dz-error-mark {
    opacity: 1 !important;
}
.dropzone .dz-preview.dz-success .dz-success-mark {
    opacity: 1 !important;
}

@-webkit-keyframes passing-through-custom {
    0% {
        opacity: 0;
        -webkit-transform: translateY(40px);
        transform: translateY(40px);
    }
    30%, 70% {
        opacity: 1;
        -webkit-transform: translateY(0);
        transform: translateY(0);
    }
    100% {
        opacity: 1;
        -webkit-transform: translateY(0);
        transform: translateY(0);
    }
}
@-moz-keyframes passing-through-custom {
    0% {
        opacity: 0;
        -webkit-transform: translateY(40px);
        transform: translateY(40px);
    }
    30%, 70% {
        opacity: 1;
        -webkit-transform: translateY(0);
        transform: translateY(0);
    }
    100% {
        opacity: 1;
        -webkit-transform: translateY(0);
        transform: translateY(0);
    }
}
@keyframes passing-through-custom {
    0% {
        opacity: 0;
        -webkit-transform: translateY(40px);
        transform: translateY(40px);
    }
    30%, 70% {
        opacity: 1;
        -webkit-transform: translateY(0);
        transform: translateY(0);
    }
    100% {
        opacity: 1;
        -webkit-transform: translateY(0);
        transform: translateY(0);
    }
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68192587

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档