Skip to content

Instantly share code, notes, and snippets.

@shawndxl
Last active August 25, 2016 13:42
Show Gist options
  • Select an option

  • Save shawndxl/02e4de3e782af8ac94e0ecd741890cf7 to your computer and use it in GitHub Desktop.

Select an option

Save shawndxl/02e4de3e782af8ac94e0ecd741890cf7 to your computer and use it in GitHub Desktop.
JS 代码片段记录

js 保存图片 / canvas 重绘图片

思路,利用FileReader 生成image的src,这个src(base64数据)可以防止到div中作为展示,或者直接保存到数据库中,也可以插入到canvas中重绘,利用canvas.toDataURL()得到新的src(base64数据)

  • 放置到div中展示
  • 放置到canvas中展示
  • plugings alloyfinger hammerjs

整体禁止拖动,某个区域除外

document.addEventListener('touchmove', function(e) {
    if ($('.moveable').has(e.target).length) {
     return;
    }
    e.preventDefault();
  });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment