javascript - Scaling text to fit in Famo.us Surface -


यहाँ सतह है

  this.gymNameSurface = नई सतह ({size: [true, जिम [1] "", " ''), संपत्तियों: {पृष्ठभूमि का रंग: 'काला', फ़ॉन्टआकार: "2em", लाइनहाइट: '72 पीएक्स'}})   

ऐसे मामलों में जिम का नाम एक निश्चित # के अंतर्गत है वर्ण, '2em' सही आकार है उदाहरणों में जब जिम का नाम एक निश्चित # वर्णों के ऊपर है, तो यह बहुत बड़ा है।

मैं सतह के अंदर पाठ के फ़ॉन्ट आकार को गतिशील रूप से कैसे बदलूं, कहना है, मुझे सतह की चौड़ाई होना & gt; window.innerWidth / 2?

धन्यवाद

आप इसे सादे जेएस के साथ कर सकते हैं :

  var fontsize = "2em"; // कम टेक्स्ट - बड़ा फ़ॉन्ट अगर (this.options.data.gymName.properties.gymName.length & gt; 32) {fontsize = "1.4em"; // अधिक टेक्स्ट - छोटे फ़ॉन्ट आकार}   

फिर आपकी सतह के गुणों पर:

  गुण: {... fontSize: fontsize, ...}    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -