-
Notifications
You must be signed in to change notification settings - Fork 2
Add image to radio widget #34
base: react-15
Are you sure you want to change the base?
Conversation
src/widgets/radio.jsx
Outdated
choices[choiceIndex].box = [i.width, i.height]; | ||
}; | ||
choices[choiceIndex] = _.extend({}, choices[choiceIndex], { | ||
content: "![](" + reader.result + ")", |
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.
- update box
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.
done
src/widgets/image.jsx
Outdated
var reader = new FileReader(); | ||
var that = this; | ||
reader.onloadend = function() { | ||
// console.log('RESULT', reader.result); |
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.
take out console.log
src/widgets/radio.jsx
Outdated
var i = new Image(); | ||
var that = this; | ||
reader.readAsDataURL(file); | ||
reader.onloadend = function() { |
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.
和 readAsDataUrl switch
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.
done
src/widgets/radio.jsx
Outdated
i.src = reader.result; | ||
i.onload = function(){ | ||
choices[choiceIndex].box = [i.width, i.height]; | ||
}; |
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.
i 這塊 不需要
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.
done
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.
這塊應該要留著,這裡釋放update box w h
src/widgets/radio.jsx
Outdated
} | ||
}, | ||
|
||
toggleUseBoxSize: function(choiceIndex) { |
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.
開舊的 radio 題目看看
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.
done 有warning, 有error,按checkbox會有can't read box[0] 因為box是undefined 但是不影響使用,
src/widgets/radio.jsx
Outdated
<BlurInput | ||
type="number" | ||
value={choice.box ? parseInt(choice.box[0]) : null} | ||
onChange={value => { |
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.
: null 改成 0
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.
不應該改,他是吃string,反而是把type = number拿掉 因為沒有用
src/widgets/radio.jsx
Outdated
// so what we do here is to make a image file and set base64 part of the content as src | ||
var resizeImage = new Image(); | ||
resizeImage.src = choice.content.match(/(!\[\])\((.*)\)/)[2]; | ||
resizeImage.onload = function() { |
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.
onload 查值
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.
什麼時候開始讀resizeImage.src
onload 哪時
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.
object.onload 是load完才跑
FileReader.onloadend 是另外的 也是read完file才跑
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.
ker
var choices = this.props.choices.slice(); | ||
choices[choiceIndex] = _.extend({}, choices[choiceIndex], { | ||
content: newContent | ||
content: newWidget |
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.
onWidgetChange沒有用到,可以刪除
No description provided.