Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Add image to radio widget #34

Open
wants to merge 36 commits into
base: react-15
Choose a base branch
from

Conversation

pytseng-junyi
Copy link

No description provided.

choices[choiceIndex].box = [i.width, i.height];
};
choices[choiceIndex] = _.extend({}, choices[choiceIndex], {
content: "![](" + reader.result + ")",

Choose a reason for hiding this comment

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

  • update box

Copy link
Author

Choose a reason for hiding this comment

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

done

var reader = new FileReader();
var that = this;
reader.onloadend = function() {
// console.log('RESULT', reader.result);
Copy link
Author

Choose a reason for hiding this comment

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

take out console.log

var i = new Image();
var that = this;
reader.readAsDataURL(file);
reader.onloadend = function() {
Copy link
Author

Choose a reason for hiding this comment

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

和 readAsDataUrl switch

Copy link
Author

Choose a reason for hiding this comment

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

done

i.src = reader.result;
i.onload = function(){
choices[choiceIndex].box = [i.width, i.height];
};
Copy link
Author

Choose a reason for hiding this comment

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

i 這塊 不需要

Copy link
Author

Choose a reason for hiding this comment

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

done

Copy link
Author

Choose a reason for hiding this comment

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

這塊應該要留著,這裡釋放update box w h

}
},

toggleUseBoxSize: function(choiceIndex) {
Copy link
Author

Choose a reason for hiding this comment

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

開舊的 radio 題目看看

Copy link
Author

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 但是不影響使用,

<BlurInput
type="number"
value={choice.box ? parseInt(choice.box[0]) : null}
onChange={value => {
Copy link
Author

Choose a reason for hiding this comment

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

: null 改成 0

Copy link
Author

Choose a reason for hiding this comment

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

不應該改,他是吃string,反而是把type = number拿掉 因為沒有用

// 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() {
Copy link
Author

Choose a reason for hiding this comment

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

onload 查值

Copy link
Author

Choose a reason for hiding this comment

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

什麼時候開始讀resizeImage.src
onload 哪時

Copy link
Author

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才跑

Copy link
Author

@pytseng-junyi pytseng-junyi left a 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
Copy link
Author

@pytseng-junyi pytseng-junyi Jul 17, 2017

Choose a reason for hiding this comment

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

onWidgetChange沒有用到,可以刪除

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants