From the Super Mario Wiki
Dangling Ghosts are enemies encountered in World 5 of Super Mario World 2: Yoshi's Island. Resembling Caged Ghosts, their only move is to swing back and forth on the ceiling similarly to a pendulum, in an attempt to hit the Yoshi or Baby Mario. They can be defeated temporarily using the usual method (spitting another enemy at them or shooting an egg), and they'll retract, allowing the player to pass through. After a few seconds, they will return to their constant swinging back and forth.
Names in other languages