में हर बार टेम्पलेट को पल्स करें जब भी यह हर बार टेम्पलेट पल्स को प्रस्तुत किया जाता है। क्या प्रस्तुत किया जा रहा है यह देखने के लिए एक दृश्य डीबगिंग उपकरण है। तो मैं ऐसा कुछ कल्पना करता हूं जब एक टेम्पलेट (एक छोटा सेगमेंट) प्रदान किया जाता है, इसका पृष्ठभूमि रंग लाल पर सेट होता है और फिर यह लाल रंग धीरे-धीरे मूल पृष्ठभूमि रंग में फिसल जाता है या पृष्ठभूमि जो कुछ भी था (भले ही यह पारदर्शी था)। तो अगर मैं देखता हूं कि कुछ समय लाल है, तो मुझे पता है कि इसे हर समय फिर से खींचा जा रहा है।मेटीर
Q
मेटीर
6
A
उत्तर
2
@Hubert ओजी से कोड और this blog post से एक विचार के आधार पर मैंने उल्का प्रतिपादन के लिए निम्नलिखित डिबगिंग कोड बनाया करना चाहते हैं:
pulseNode = (i, node) ->
return unless node.style
$node = $(node)
prePulseCss = $node.data('prePulseCss') ? node.style.cssText
prePulseBackgroundColor = $node.data('prePulseBackgroundColor') ? $node.css('backgroundColor')
$node.data(
'prePulseCss': prePulseCss
'prePulseBackgroundColor': prePulseBackgroundColor
).css('backgroundColor', 'rgba(255,0,0,0.5)').stop('pulseQueue', true).animate(
backgroundColor: prePulseBackgroundColor
,
duration: 'slow'
queue: 'pulseQueue'
done: (animation, jumpedToEnd) ->
node.style.cssText = prePulseCss
).dequeue 'pulseQueue'
pulse = (template) ->
$(template.firstNode).nextUntil(template.lastNode).addBack().add(template.lastNode).each pulseNode
_.each Template, (template, name) ->
oldRendered = template.rendered
counter = 0
template.rendered = (args...) ->
console.debug name, "render count: #{ ++counter }"
oldRendered.apply @, args if oldRendered
pulse @
1
यहां एक साधारण झपकी है। एनिमेटिंग पृष्ठभूमि रंग को अतिरिक्त पुस्तकालयों की आवश्यकता होती है, jQuery animate backgroundColor देखें।
var pulseNode = function(node) {
if(!node.style) return;
var prev = node.style['background-color'] || 'rgba(255,0,0,0)';
$(node).css('background-color', 'red');
setTimeout(function() {
$(node).css('background-color', prev);
}, 1000);
};
pulse = function(template) {
for(var node = template.firstNode; true; node = node.nextSibling) {
pulseNode(node);
if(node === template.lastNode) return;
}
}
अब, प्रत्येक टेम्पलेट के लिए आप इस का उपयोग करने,
Template.asdf.rendered = function() {
pulse(this);
}
संबंधित मुद्दे
- 1. मेटीर
- 2. मेटीर
- 3. मेटीर
- 4. मेटीर
- 5. मेटीर
- 6. मेटीर
- 7. मेटीर
- 8. मेटीर
- 9. मेटीर
- 10. मेटीर
- 11. मेटीर
- 12. मेटीर
- 13. मेटीर
- 14. मेटीर
- 15. मेटीर ऐप
- 16. मेटीर जेएस
- 17. मेटीर ऐप
- 18. वापसी मेटीर। परिणाम
- 19. मेटीर उपयोगकर्ता दस्तावेज़
- 20. मेटीर ऐप (लोकलहोस्ट)
- 21. वास्तव में मेटीर
- 22. मोचा परीक्षण मेटीर
- 23. बूटस्ट्रैप 3 टेबल मेटीर
- 24. मेटीर में JSON एंडपॉइंट
- 25. मेटीर जेएस में सबडोमेन रूटिंग
- 26. मेटीर/हैंडलबार्स में टेम्पलेट डीबग कैसे करें?
- 27. मेटीर फ़ाइलों को अनदेखा कैसे करें?
- 28. मेटीर का पैकेज.जेएस कैसे काम करता है?
- 29. आप एक आरईएसटी एपीआई कैसे बनाते हैं और मेटीर
- 30. आप मेटीर में क्लाइंट को सशर्त रूप से डेटा कैसे भेजते हैं?
यदि आप स्थिर सीएसएस सेट करने के लिए jQuery का उपयोग कर रहे हैं, तो आप अतिरिक्त पुस्तकालयों के बिना 'एनिमेट' का भी उपयोग कर सकते हैं, नहीं? – Mitar
मेरे पास जो मुद्दा है वह यह है कि यह पृष्ठभूमि को मूल स्थिति में पुनर्स्थापित नहीं करता है। – Mitar