Skip to content

Commit

Permalink
增加一个在 sketch 中实时预览的能力。
Browse files Browse the repository at this point in the history
  • Loading branch information
bugluo committed Sep 17, 2017
1 parent 8560823 commit 9568008
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 2 deletions.
8 changes: 7 additions & 1 deletion WeSketch.sketchplugin/Contents/Sketch/commonPreviewJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,14 @@ var commonPreviewJson = function (context, filePath, show) {
var size = artBoards[i].absoluteRect().size().width;
if (size == 320 || size == 414 || size == 375) {
scale = 2;
exportSVGJson.width = parseInt(encodeURIComponent(size));
}else if(size == 750){
exportSVGJson.width = 375;
}else if(size == 640){
exportSVGJson.width = 320;
}else{
exportSVGJson.width = 414;
}
// getSliceHeader(artBoards[i],context,'header'+pageCount,filePath,scale);
exportPNG(artBoards[i], context, filePath, scale, newPreviewObject);
}
relationship(context.document,newPreviewObject);
Expand Down
8 changes: 8 additions & 0 deletions WeSketch.sketchplugin/Contents/Sketch/i18n/manifest-enUS.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@
"shortcut": "",
"handler" : "hidePreview"
},
{
"name" : "Show Preview",
"identifier" : "showPreview",
"script" : "showPreview.js",
"shortcut": "",
"istool":"",
"handler" : "onRun"
},
{
"name" : "Local Preview",
"identifier" : "localPreview",
Expand Down
8 changes: 8 additions & 0 deletions WeSketch.sketchplugin/Contents/Sketch/i18n/manifest-zhCN.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@
"shortcut": "",
"handler" : "hidePreview"
},
{
"name" : "直接预览",
"identifier" : "showPreview",
"script" : "showPreview.js",
"shortcut": "",
"istool":"",
"handler" : "onRun"
},
{
"name" : "生成本地预览",
"identifier" : "localPreview",
Expand Down
8 changes: 8 additions & 0 deletions WeSketch.sketchplugin/Contents/Sketch/i18n/manifest-zhTW.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@
"shortcut": "",
"handler" : "hidePreview"
},
{
"name" : "直接預覽",
"identifier" : "showPreview",
"script" : "showPreview.js",
"shortcut": "",
"istool":"",
"handler" : "onRun"
},
{
"name" : "生成本地預覽",
"identifier" : "localPreview",
Expand Down
8 changes: 7 additions & 1 deletion WeSketch.sketchplugin/Contents/Sketch/preview.html
Original file line number Diff line number Diff line change
Expand Up @@ -2449,6 +2449,9 @@
$('.loadding').show();
var loader = new PxLoader();
for (var i in content) {
if(i == 'width'){
continue;
}
if (content[i].content.name) {
loader.addImage('./' + content[i].content.name + '.png');
}
Expand All @@ -2471,7 +2474,7 @@



var size = 414;
var size = content.width;
var zoom = window.innerWidth / size;
var zindex = 1;
var firstPage;
Expand All @@ -2493,6 +2496,9 @@

var dom = [];
for (var i in content) {
if(i == 'width'){
continue;
}
if (content[i].firstPage) {
history.pushState(null, "", "?page=" + content[i].content.name);
firstPage = content[i].content.name;
Expand Down

0 comments on commit 9568008

Please sign in to comment.