-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix canvas-ribbon error. #1932
Fix canvas-ribbon error. #1932
Conversation
canvasRibbon.width = width * dpr; // 返回实际宽高 | ||
canvasRibbon.height = height * dpr; | ||
ctx.scale(dpr, dpr); // 水平、竖直方向缩放 | ||
ctx.globalAlpha = config.alpha; // 图形透明度 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'config' is not defined.
|
||
// 获取自定义配置 | ||
var ribbon = document.getElementById('ribbon'); // 当前加载的script | ||
config = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'config' is not defined.
ctx.fillStyle = '#' + (cos(r) * 127 + 128 << 16 | cos(r + PI_2 / 3) * 127 + 128 << 8 | cos(r + PI_2 / 3 * 2) * 127 + 128).toString(16); | ||
ctx.fill(); // 根据当前样式填充路径 | ||
path[0] = path[1]; // 起点更新为当前终点 | ||
path[1] = {x: nextX, y: nextY} // 更新终点 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon.
|
||
r -= PI_2 / -50; | ||
// 随机生成并设置canvas路径16进制颜色 | ||
ctx.fillStyle = '#' + (cos(r) * 127 + 128 << 16 | cos(r + PI_2 / 3) * 127 + 128 << 8 | cos(r + PI_2 / 3 * 2) * 127 + 128).toString(16); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long.
Unexpected use of '<<'.
Unexpected use of '|'.
path = [{x: 0, y: height * 0.7 + RIBBON_WIDTH}, {x: 0, y: height * 0.7 - RIBBON_WIDTH}]; | ||
// 路径没有填满屏幕宽度时,绘制路径 | ||
while (path[1].x < width + RIBBON_WIDTH) { | ||
draw(path[0], path[1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon.
var ribbon = document.getElementById('ribbon'); // 当前加载的script | ||
config = { | ||
zIndex: getAttr(ribbon, "zIndex", -1), // z-index | ||
alpha: getAttr(ribbon, "alpha", 0.6), // alpha |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mixed double and single quotes.
// 获取自定义配置 | ||
var ribbon = document.getElementById('ribbon'); // 当前加载的script | ||
config = { | ||
zIndex: getAttr(ribbon, "zIndex", -1), // z-index |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mixed double and single quotes.
} | ||
|
||
function getAttr(script, attr, default_val) { | ||
return Number(script.getAttribute(attr)) || default_val; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identifier 'default_val' is not in camel case.
targetA = false | ||
} | ||
|
||
function getAttr(script, attr, default_val) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identifier 'default_val' is not in camel case.
targetA = true; | ||
!function () { | ||
document.addEventListener('touchmove', function (e) { | ||
e.preventDefault() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon.
Thanks! |
@geekrainy but i see bug in your blog: https://rainylog.com/tags/ — sidebar get wrong position. It is normal to have so many errors in this script? |
@ivan-nginx I have noticed this problem, it is not caused by this script. This is my own branch of the problem, I will fix it. |
@geekrainy ok, it's somewhere in scripts with sidebar alignment. See |
@geekrainy can u comment #1935 issue? |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
If use plugin hexo-all-minifier, will report an error:
So I upgrade this script file from https://github.com/zproo/canvas-ribbon.
Issue Number(s): N/A
What is the new behavior?
Now error is not appear.
Does this PR introduce a breaking change?