From 184828c3e7695c34a5c910ec5fb88e96b2ee5143 Mon Sep 17 00:00:00 2001 From: shylinux Date: Wed, 26 Aug 2020 09:14:42 +0800 Subject: [PATCH] opt some --- frame.js | 4 ++-- plugin/input.js | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/frame.js b/frame.js index abcb997d..698bd067 100644 --- a/frame.js +++ b/frame.js @@ -639,9 +639,9 @@ Volcanos("onkeypop", {help: "键盘交互", list: [], _init: function(can) { }} })}]) - can.Timer({interval: 100}, function() { + can.Timer({interval: 1000}, function() { can.page.Select(can, ui.high, "div.char", function(item) { - item.offsetHeight > 0 && can.page.Modify(can, item, {style: {height: item.offsetHeight-4+"px"}}) + item.offsetHeight > 0 && can.page.Modify(can, item, {style: {height: item.offsetHeight-1+"px"}}) }) }) diff --git a/plugin/input.js b/plugin/input.js index 71e41e32..1bb90248 100644 --- a/plugin/input.js +++ b/plugin/input.js @@ -43,11 +43,23 @@ Volcanos("onaction", {help: "控件交互", list: [], }, onkeydown: function(event, can) { event.key !== " " && can.page.Select(can, document.body, "div.char."+event.key, function(item) { - can.page.Modify(can, item, {style: {height: item.offsetHeight+100+"px"}}) + can.page.Modify(can, item, {style: {background: "rgb(" + +parseInt(Math.random()*255)+"," + +parseInt(Math.random()*255)+"," + +parseInt(Math.random()*255)+")", + height: item.offsetHeight+100+"px"}}) }) switch (event.key) { + case " ": + can.page.Select(can, document.body, "div.char", function(item) { + can.page.Modify(can, item, {style: {height: item.offsetHeight+100+"px"}}) + }) + break case "Enter": + event.key !== " " && can.page.Select(can, document.body, "div.char", function(item) { + can.page.Modify(can, item, {style: {height: 0+"px"}}) + }) if (event.target.tagName == "TEXTAREA") { break }