我试图在以疯狂的速度创建多个DIV时找出有关性能的最佳实践.例如,在每个.mousemove事件中......
$('head').append("<style>.draw {width: 20px; height: 20px; position:fixed;</style>");
$(document).mousemove(function(mouseMOVE) {
//current mouse position
var mouseXcurrent = mouseMOVE.pageX;
var mouseYcurrent = mouseMOVE.pageY;
//function to create div
function mouseTRAIL(mouseX, mouseY, COLOR) {
$('body').append("<div class='draw' style='top:" + mouseY + "px; left:" + mouseX + "px; background: " + COLOR + ";'></div>");
}
// function call to create <div> at current mouse positiion
mouseTRAIL(mouseXcurrent, mouseYcurrent, '#00F');
// Remove <div>
setTimeout(function() {
$('.draw:first-child').remove();
}, 250);
});
Run Code Online (Sandbox Code Playgroud)
所以,这一切都很好用,但它的效率很低(尤其是当我尝试填充每个鼠标移动位置之间的空间时).这是一个例子......
$('head').append("<style>.draw {width: 20px; height: 20px; position:fixed;</style>");
$(document).mousemove(function(mouseMOVE) {
//current …Run Code Online (Sandbox Code Playgroud) 只是尝试在插件激活上创建一个新的数据库表.为了对生活的热爱,我无法弄清楚为什么这不起作用.
function super_simple_photo_activate() {
global $wpdb;
$table_name = $wpdb->prefix."super_simple_photo_options";
if ($wpdb->get_var('SHOW TABLES LIKE '.$table_name) != $table_name) {
$sql = 'CREATE TABLE '.$table_name.'(
thumbs_max VARCHAR(3),
image_max VARCHAR(4),
image_quality VARCHAR(3),
PRIMARY KEY (id))';
require_once(ABSPATH.'wp-admin/includes/upgrade.php');
dbDelta($sql);
add_option("super_simple_photo_db_version", "1.0");
}
}
register_activation_hook(__FILE__, 'super_simple_photo_activate');
Run Code Online (Sandbox Code Playgroud)
我已经花了至少5个小时修补这个,但没有运气,也没有错误激活.
诀窍是什么 - id INTEGER NOT NULL - 感谢t.thielemans
$sql = 'CREATE TABLE '.$table_name.'(
id INTEGER NOT NULL,
thumbs_max VARCHAR(3),
image_max VARCHAR(4),
image_quality VARCHAR(3),
PRIMARY KEY (id))';
Run Code Online (Sandbox Code Playgroud) 我对人们对轻量级独立JavaScript动画库的"真实世界"使用意见/建议感兴趣.所以,不需要像jQuery,dojo等那样的"全功能"JavaScript库......
注意:
- 请不要使用面向HTML5画布的库(例如processing.js).
- Css3支持是奖金,但不是必需的.
- 效率越高越好!
- 如果您愿意,请让我和其他人知道您推荐的建议.
谢谢.
我不确定我是否正确地表达了问题标题; 请考虑以下内容以澄清......
(function() {
var foo = {
bar: function() {
// Is it possible to reference 'this' as the
// initializing 'object' aka 'e' and not 'foo' ?
// The easy part, currently because 'this' refers to 'foo',
// is returning 'this' aka 'foo' so that chaining can occur
return this;
},
other: function() {
return this;
}
};
Event.prototype.foo = foo;
}());
// usage
document.onmousemove = function(e) {
e.foo.bar().other();
};
Run Code Online (Sandbox Code Playgroud)
我怎样才能访问this方法/道具,foo但是this引用了初始的object …
javascript ×3
animation ×1
database ×1
function ×1
html ×1
inheritance ×1
jquery ×1
methods ×1
performance ×1
this ×1
wordpress ×1