Skip to content

Commit

Permalink
v2.1.2 release
Browse files Browse the repository at this point in the history
support configuration to pause the movement when highlight a tag or not
  • Loading branch information
D0n9X1n committed Mar 18, 2020
1 parent 192e480 commit caddef0
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 42 deletions.
2 changes: 1 addition & 1 deletion README.ZH.md
Expand Up @@ -117,7 +117,7 @@ tag_cloud:
textHeight: 25
outlineColor: '#E2E1D1'
maxSpeed: 0.5
pauseOnSelected: false # true 意味着当选中对应 tag 时,停止转动
```
+ 然后使用 `hexo c && hexo g && hexo s` 来享受属于你自己的独一无二的标签云吧。

Expand Down
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -118,6 +118,7 @@ tag_cloud:
textHeight: 25
outlineColor: '#E2E1D1'
maxSpeed: 0.5 # range from [0.01 ~ 1]
pauseOnSelected: false # true means pause the cloud tag movement when highlight a tag
```
+ then use `hexo clean && hexo g && hexo s` to enjoy your different tag cloud

Expand Down
89 changes: 49 additions & 40 deletions index.js
Expand Up @@ -51,6 +51,7 @@ hexo.extend.filter.register("after_generate", function(post) {
var textHeight = "15";
var outlineColor = "#E2E1C1";
var maxSpeed = "0.03";
var pauseOnSelected = true;

if (hexo.config.tag_cloud) {
if (hexo.config.tag_cloud.textColor) {
Expand All @@ -68,55 +69,63 @@ hexo.extend.filter.register("after_generate", function(post) {
if (hexo.config.tag_cloud.maxSpeed) {
maxSpeed = hexo.config.tag_cloud.maxSpeed;
}
if (hexo.config.tag_cloud.pauseOnSelected != undefined) {
pauseOnSelected = hexo.config.tag_cloud.pauseOnSelected;
}
}

var tagCloudJsContent =
"function addLoadEvent(func) {\n" +
" var oldonload = window.onload;\n" +
" if (typeof window.onload != 'function') {\n" +
" window.onload = func;\n" +
" } else {\n" +
" window.onload = function() {\n" +
" oldonload();\n" +
" func();\n" +
" }" +
" }\n" +
"}\n" +
"addLoadEvent(function() {\n" +
" console.log('tag cloud plugin rock and roll!');\n" +
" try {\n" +
" TagCanvas.textFont = '${textFont}';\n" +
" TagCanvas.textColour = '${textColor}';\n" +
" TagCanvas.textHeight = ${textHeight};\n" +
" TagCanvas.outlineColour = '${outlineColor}';\n" +
" TagCanvas.maxSpeed = ${maxSpeed};\n" +
" TagCanvas.outlineMethod = 'block';\n" +
" TagCanvas.minBrightness = 0.2;\n" +
" TagCanvas.depth = 0.92;\n" +
" TagCanvas.pulsateTo = 0.6;\n" +
" TagCanvas.initial = [0.1,-0.1];\n" +
" TagCanvas.decel = 0.98;\n" +
" TagCanvas.reverse = true;\n" +
" TagCanvas.hideTags = false;\n" +
" TagCanvas.shadow = '#ccf';\n" +
" TagCanvas.shadowBlur = 3;\n" +
" TagCanvas.weight = false;\n" +
" TagCanvas.imageScale = null;\n" +
" TagCanvas.fadeIn = 1000;\n" +
" TagCanvas.clickToFront = 600;\n" +
" TagCanvas.Start('resCanvas');\n" +
" TagCanvas.tc['resCanvas'].Wheel(false)\n" +
" } catch(e) {\n" +
" console.log(e);\n" +
" document.getElementById('myCanvasContainer').style.display = 'none';\n" +
" }\n" +
"});\n";
" function addLoadEvent(func) {\n" +
" var oldonload = window.onload;\n" +
" if (typeof window.onload != 'function') {\n" +
" window.onload = func;\n" +
" } else {\n" +
" window.onload = function() {\n" +
" oldonload();\n" +
" func();\n" +
" }\n" +
" }\n" +
" }\n" +
"\n" +
" addLoadEvent(function() {\n" +
" console.log('tag cloud plugin rock and roll!');\n" +
"\n" +
" try {\n" +
" TagCanvas.textFont = '${textFont}';\n" +
" TagCanvas.textColour = '${textColor}';\n" +
" TagCanvas.textHeight = ${textHeight};\n" +
" TagCanvas.outlineColour = '${outlineColor}';\n" +
" TagCanvas.maxSpeed = ${maxSpeed};\n" +
" TagCanvas.freezeActive = ${pauseOnSelected};\n" +
" TagCanvas.outlineMethod = 'block';\n" +
" TagCanvas.minBrightness = 0.2;\n" +
" TagCanvas.depth = 0.92;\n" +
" TagCanvas.pulsateTo = 0.6;\n" +
" TagCanvas.initial = [0.1,-0.1];\n" +
" TagCanvas.decel = 0.98;\n" +
" TagCanvas.reverse = true;\n" +
" TagCanvas.hideTags = false;\n" +
" TagCanvas.shadow = '#ccf';\n" +
" TagCanvas.shadowBlur = 3;\n" +
" TagCanvas.weight = false;\n" +
" TagCanvas.imageScale = null;\n" +
" TagCanvas.fadeIn = 1000;\n" +
" TagCanvas.clickToFront = 600;\n" +
" TagCanvas.lock = false;\n" +
" TagCanvas.Start('resCanvas');\n" +
" TagCanvas.tc['resCanvas'].Wheel(true)\n" +
" } catch(e) {\n" +
" console.log(e);\n" +
" document.getElementById('myCanvasContainer').style.display = 'none';\n" +
" }\n" +
" });\n";

tagCloudJsContent = tagCloudJsContent.replace("${textFont}", textFont);
tagCloudJsContent = tagCloudJsContent.replace("${textColor}", textColor);
tagCloudJsContent = tagCloudJsContent.replace("${textHeight}", textHeight);
tagCloudJsContent = tagCloudJsContent.replace("${outlineColor}", outlineColor);
tagCloudJsContent = tagCloudJsContent.replace("${maxSpeed}", maxSpeed);
tagCloudJsContent = tagCloudJsContent.replace("${pauseOnSelected}", pauseOnSelected);

fs.writeFile(tagcloudPubPath, tagCloudJsContent);
log.info("---- END COPYING TAG CLOUD FILES ----");
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -34,5 +34,5 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"version": "2.1.1"
"version": "2.1.2"
}

0 comments on commit caddef0

Please sign in to comment.