 
 		badylize: ->
 			return if @badylized
-			@originalWidth = @$el.width()
+			@containerInnerWidth = @measureInnerWidth @$originalParent
 			@originalHeight = @$el.height()
 
 			@badylInnerHeight = @originalHeight + @config.offset * 2
 
-			windowHeight = $(window).height()
-			return if @originalHeight is 0
+			# return if @originalHeight is 0
 
 			@badylHeight = @$refEl.height() + @config.offset * 2
 

			
			@badylized = yes

		rebadylize: ->
			@rebadylizeFromState = @state
			@debadylize()
			@badylize()

		debadylize: ->
			return unless @badylized
			@unbindEvents()
			@$badylContainer.replaceWith @$el = @$originalElement
			@$el.data "badyl", @
			@badylized = no
			@state = null

		bindEvents: ->
			$(window).on "scroll", @windowScrollHandler = (e) =>
				@refreshInnerCss()
			
			smartResizeTimeout = null
			$(window).on "resize", @windowResizeHandler = (e) =>
				clearTimeout smartResizeTimeout if smartResizeTimeout
				smartResizeTimeout = setTimeout =>
					@rebadylize()
					smartResizeTimeout = null
				, 100

		unbindEvents: ->

					margin: "-#{@config.offset}px 0"
				.append @$badylInner = $("""<div>""")
					.css
						width: "#{@containerInnerWidth}px"
						height: "#{@badylInnerHeight}px"
						padding: "#{@config.offset}px 0"
					.append @$originalElement = @$el.clone()
