There are many cases where the present participle and the infinitive may be exchanged. Sometimes the infinitive marker "to" is dropped, sometimes not. I believe both act as nouns in this case.
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.