jQuery FadeOut效果速度/持续时间不起作用

时间:2018-06-23 13:47:44

标签: jquery slider fadeout

您好,我正在尝试在1秒内对元素进行fadeOut效果,但是这种效果不符合我想要的速度/持续时间。元素会直接淡出。

这是我在代码笔上的代码的链接[在此处输入链接描述] [1]

const fs = require('fs');
const readLine = require('readline');
const { Readable } = require('stream');
const output = fs.createWriteStream(__dirname + '/copy.json');

//creating readline interface
const lineReader = readLine.createInterface({
    input: fs.createReadStream(__dirname + '/IN.txt')
});

const fields = ['country', 'pin', 'place', 'state', 'code', 'division',         'admin', 'mandal', 'xxx', 'lat', 'long'];

let lineCount = 0;
let writeAllowed = true; //Turns to false when stream.write starts     returning false
let paused = false; //Pause Readline
let buffstr = ""; //To handle leaks after calling readLine pause()

//reading data from text file line by line and pushing it to an array
lineReader.on('line', function (line) {
    lineCount++;
    let words = line.split('\t');
    let lineJson = getLineContent(fields, words);

    if (paused) {
      if(lineCount > 1) {
        buffstr = buffstr + ",";
      }
      buffstr = buffstr + JSON.stringify(lineJson, null, 4);
    }
    else {
      if(!writeAllowed) {
        lineReader.pause();
      }
      lineCount === 1 ? writeMe('[') : writeMe(",");
      writeMe(JSON.stringify(lineJson, null, 4));
    }
});

lineReader.on('pause', function() {
   paused = true;
});

lineReader.on('resume', function() {
   paused = false;
});

lineReader.on('close', function (line) {
    output.write(buffstr);
    output.write(']');
    output.end();
    console.log(`***Finished*** Memory heap used:     ${process.memoryUsage().heapUsed / 1024 / 1024} MB`);
});

function writeMe(str){
   if(writeAllowed){
      writeAllowed = writeAllowed && output.write(str);
   }
   else{
      buffstr += str;
      output.once('drain', function() {
         lineReader.resume();
         output.write(buffstr);
         buffstr = ""; //Possible scope of improvement. Need to check if     any race condition
         writeAllowed = true;
      });
   }
}

//words array will be like ["IN","744301", "Mus Andaman & Nicobar     Islands", "01 Nicobar 638 Carnicobar" , "9.2333", "92.7833","4"]
//creating obj with fields and words
function getLineContent(fields, words) {
    var obj = {};
    for(let i = 0; i < fields.length; i++) {
        obj[fields[i]] = words[i];
    }
    return obj;
}

1 个答案:

答案 0 :(得分:0)

这是您要执行的操作的JS版本:https://codepen.io/modelcroissant/pen/zaaEbb 我很无聊,所以我决定为您的问题构建一个基于数组的JQuery解决方案,该解决方案还清理了您的functionCeption代码,并从html删除了部分内容,以减少html的混乱。 BUUUUUT 您真正要做的就是删除与JS代码样式冲突的css过渡样式。

*{
      -webkit-transition: all .5s ease-in-out;
    -moz-transition: all .5s ease-in-out;
    -o-transition: all .5s ease-in-out;
    -ms-transition: all .5s ease-in-out;
    transition: all .5s ease-in-out;

}