Skip to content
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

Merged
merged 1 commit into from
Oct 11, 2017
Merged

Fix canvas-ribbon error. #1932

merged 1 commit into from
Oct 11, 2017

Conversation

geekrainy
Copy link
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our guidelines.
  • Tests for the changes have been added (for bug fixes / features).
    • Muse | Mist have been tested.
    • Pisces | Gemini have been tested.
  • Docs have been added / updated (for bug fixes / features).

PR Type

What kind of change does this PR introduce?

  • Bugfix.
  • Feature.
  • Code style update (formatting, local variables).
  • Refactoring (no functional changes, no api changes).
  • Build related changes.
  • CI related changes.
  • Documentation content changes.
  • Other... Please describe:

What is the current behavior?

If use plugin hexo-all-minifier, will report an error:

ERROR Asset render failed: lib/canvas-ribbon/canvas-ribbon.js

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.

  • Screens with this changes: N/A
  • Link to demo site with this changes: N/A

Does this PR introduce a breaking change?

  • Yes.
  • No.

canvasRibbon.width = width * dpr; // 返回实际宽高
canvasRibbon.height = height * dpr;
ctx.scale(dpr, dpr); // 水平、竖直方向缩放
ctx.globalAlpha = config.alpha; // 图形透明度

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 = {

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} // 更新终点

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);

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])

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

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

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;

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) {

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()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon.

@ivan-nginx ivan-nginx merged commit 8f3e447 into iissnan:master Oct 11, 2017
@ivan-nginx
Copy link
Collaborator

Thanks!

@ivan-nginx ivan-nginx added this to the v5.1.4 milestone Oct 11, 2017
@ivan-nginx
Copy link
Collaborator

@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?

@geekrainy
Copy link
Contributor Author

@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 geekrainy deleted the fix/ribbon branch October 11, 2017 05:58
@ivan-nginx
Copy link
Collaborator

@geekrainy ok, it's somewhere in scripts with sidebar alignment. See utils.js, pisces.js, post-details.js.

@ivan-nginx
Copy link
Collaborator

@geekrainy can u comment #1935 issue?

@ivan-nginx ivan-nginx added the Bug label Oct 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants